setting multiple instances of sprite to another sprite with multiple instances

From the Asset Store
Be quick and choose the right answer for the shown equation.
  • hey. trying out construct3 demo. i have previous experience from the original construct classic. my question is difficult to explain, but i'll try my best:

    so, i have a sprite1. then i have a sprite2. sprite1 has 3 image points. on level start, i want to spawn 3 instances of sprite2, and always set their position to sprite1, on their own image points. so far so good, i can do that.

    but, i also need to have multiple instances of sprite1, and thats where everything goes messy. i get weird results, like sprite2 only being correctly placed on one instance of sprite1 but the others are not showing correctly, for example only being set on a single image point or not at all, depending on what i try.

    what would be the correct way to do this? honestly it's probably something simple but i'm just lost on this one. trying to manipulate multiple instances of an object always makes my brain fart hard.

  • Did you use spawn or create? I think if you use spawn sprite 2 from sprite 1 then it should pick correctly and relate the sprite 2 to the sprite 1. So you say for each sprite 1, spawn sprite 2 at image point 1 should work for each, try that.

  • Sorry it took me a while to reply. yes i got it working. it was surprisingly straightforward. i remember it being a bit more complex on the old construct classic.

    i'm not sure if i should spam and post a new topic or not, so i'll just ask here:

    again, i have a sprite with multiple instances, each having increasing private variable value(1,2,3,4,5 and so forth). how can i interact between two instances that have the highest values? for example, between instances with values 12 and 13, 7 and 8, 23 and 24 and so forth? how do i pick those?

  • Just picking again, but I didn't really understand what you're asking

  • sorry, i'll try to elaborate. basically i just want to pick the second highest value of the private variable, at any given point. i can't simply pick a number, because the private variable value is constantly changing.

    is it something like:

    -pick sprite instance with highest value

    -- sprite.value equals sprite.(pv) -1

    ?

  • you can use the System Pick by Evaluate to get them sorted into the right order

    "Pick Sprite by Evaluate Sprite.pv"

    then you can get the second last one by either picking the nth instance in a sub event, which would be "Pick Sprite instance Sprite.pickedcount-2"

    (-2 because instances start at 0 for the first one)

    or you can directly access the variable by saying Sprite(Sprite.pickedcount-2).pv

    EDIT: I just tried again, and pick by evaluate is not working the way I remember... I will post again when I can...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • so, instead of Pick by evaluate, I guess the best option is to use "For Each Sprite order by Sprite.pv descending"

    and then stop the loop when loopindex is 1.

  • so, instead of Pick by evaluate, I guess the best option is to use "For Each Sprite order by Sprite.pv descending"

    and then stop the loop when loopindex is 1.

    hmm, i'm not sure if i understand what you mean by the loopindex.

    could you post an example about this as a pseudo code or such?

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