Multiple instances of a given sprite

This forum is currently in read-only mode.
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Is there a way to reference each instance of a given sprite? I wish to create an array for each instance of an enemy sprite, but I see no way to do this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can pick via a private variable, but referencing multiple instances in your actions is a bit tricky.

  • Could you explain this in more detail? I was thinking of perhaps using a custom behavior, but I have no idea where to start making a behavior...

  • Maybe I didn't understood you right, but you can use different Z in Array object for each enemy. For ex. Enemy's sprite UID = 1 array Z = 1. If I'm wrong see my sig)

  • Could you explain this in more detail? I was thinking of perhaps using a custom behavior, but I have no idea where to start making a behavior...

    To pick an instance simply add a private variable and assign each instance a different value IE:

    sprite.privatevariable('a')= 1, sprite.privatevariable('a')= 2. You can assign the values in the editor, or on creation of the instance. Then you just compare the private variable to pick that instance.

    Thats the easy part.

    The hard part is when you want to use more than one instance... behaviors aren't built to pick an instance via a pv.

    However, you can create a custom behavior using some of the built in expressions.

    http://www.scirra.com/forum/viewtopic.php?f=3&t=7350&p=57411&hilit=chain+python#p57411

  • I dont entirely understand what you are trying to say there, but I did look at the link provided and the cap files in that thread.

    The method wont work for me because the object (key) has more than one state (used and un-used animation, private variable). I need to ensure that the right array is linked to the right key.

    In the chain example, there was no difference between the different links of the chain, hence the method used there worked. As long as one of any link appears in each location, it works out fine.

  • Here's an example:

    http://dl.dropbox.com/u/5426011/examples2/snakes.cap

    Made in 0.99.96

    The sprites have two variables "group" and "num":

    "group" can be thought of as the array number the sprite is part of.

    "num" can be thought of as the key or index in the array.

    So for example to select the third sprite in group (or array) #1 two conditions are needed:

    + Sprite: Value 'group' Equal to 1

    + Sprite: Value 'num' Equal to 3

    Is that helpful?

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