manipulate differents instance of same sprite

0 favourites
  • 6 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Hi,

    I got this :

    This is working. But here's a particular case I don't get, and since it's happening very often, there must be something I don't get !

    A screenshot of the case :

    <img src="" border="0" />

    As you can see, I got 2 instances of "Insecte", first one is chasing the other.

    So far, I can have Insecte(0) and Insecte(1), displaying correct UID.

    But for some reason, once I've reach Insecte(1), I can't change values from Insecte(0).

    I've tried another approched (the disabled code in the end) with an external value to pick up the Instance but it doesn't work ...

    Can you help me ?

    Thanks a lot

  • I'm trying to tell in another way:

    Foreach Insect :

    • If Insect.hungry = 1
    • - Pick Up the Nearest Insect (who is not the same, and fit to its taste)

    So far : it's good, I got Insect (the victim) and Insect(0) (the predator)


    How do I update the predator ?

    If I make some changes to Insect, that will use the victim.

    If I pick up the predator by UID, it doesn't work, probably because i'm in the Loop "foreach Insect" ..

    There's a basic thing I don't get, if someone can tell me any method to do what I'm trying to do, it will be greatly appreciated.

    BONUS SUGGESTION : that would be awesome to get some aliases, like in mysql, like :

    • Pick up Insect.hungry = 1 as Predator
    • - Pick up nearest Insecte (not me, etc) as Victim

    Predator.target_uid = Victim.uid

    What do you think ?



  • You should use subevents.

    After you pick the insect which is hungry, pick the insect to chase in a subevent. In another subevent (as long as it is a direct subevent if your for each) if you reference an insect it will be the one originally picked.

  • Thanks. It's a good idea and I figured out that my problem was also related to a bad use of "pick nearest"

    I have to make conditions, then a sub event with just "pick nearest" to make it work.

  • Actually the sub event will only pick from the list of that instance already picked. So if one is picked, it won't see the other.

    You can use families if you aren't using the free version.

    You pick one by referencing the family it's in, and the other directly. So you have two separate picking lists.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • okay thanks. I've seen families are made to host different sprites that would share some common behavior but your technique seems good as well to separate the same sprites yes !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)