Stop and start sprites in an orderly line

0 favourites
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hello,

    I have a line of sprites that follow each other. I'd like them to come to a stop one behind another. After a short period, I want them to start moving again, but in a staggered fashion (so they don't bunch up).

    So for example: number1 sprite stops, then number2 stops behind him, then 3 and 4 and so on! After a short pause, number1 starts to move forwards again, wait 1 second, and number2 starts to follow, and so on!

    I've created something which almost works the way I want, but it's doing strange things when the sprites start to move again.

    I've included a capx, and would really appreciate it if someone could take a look, and let me know where I'm going wrong. Or if someone could point out a better way of doing this?

    capx

    Thanks everyone :)

  • Hi all,

    Can anyone help me with this please?

    As mentioned above, I've almost got my example working the way I want. But I just can't get the last bit working properly.

    The capx is fully commented, and I'm happy to answer any further questions if I've left anything out (see capx below).

    download capx

    I would really appreciate some advice, or any suggestions for a better way of doing this!

    Thanks everyone :)

  • I hope that I caught you idea that you want to spawn sprites 5 at a time with certain intervals and stop all of them when colliding with the stopsprite. I pretty much had to remake all your code. Instead of lerp you should have used bullet and on collision all sprites are stopped.

    http://www.upload.ee/files/3434199/StopSprite.capx.html

  • Hi trollface,

    Thank you for your efforts, but it's not really what I was after.

    Perhaps I can use a different example! Think of a set of traffic lights, when they turn red each car stops one behind the other. When they turn green, each car starts moving one after the other, not all at once. Does that help to explain better?

    I wanted to have my sprites stop. And restart in a staggered fashion (so number 1 starts moving, wait 1 sec and number 2 starts moving etc.).

    That's why my original example creates a new stop sprite behind each player sprite. I thought that destroying stop sprites in order would be the best way to get the players moving one after another and NOT all at once.

    Also I'm using a custom style of movement in my project, so bullet behaviour just won't work.

    Thanks again for trying to help though, I really do appreciate you taking the time to do that.    <img src="smileys/smiley20.gif" border="0" align="middle" />

    I still haven't found an answer to this problem. So if anybody has any ideas, I'd love to hear from you.

    <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Instead of using stop sprites I would measure the distance between one sprite and the other in the direction they're moving. If a certain distance is reached then stop moving, else wait a second and keep moving.

  • Hi MakubeX,

    Thanks for the help, although I'm not sure this'll work better than using stop sprites?

    I've only used the distance comparison a few times before, and I'm not quite sure how I would do what you've suggested.

    My sprites are all instances of the same object, so I don't know how I'd be able to use the distance expression (i.e. distance(player.X, player.Y, player.X, player.Y)). I guess I'd have to use the objects IID somehow?

    Thanks again for the advice, I'll certainly give it a try :)

  • You're right, if the sprites are all instances of the same object then it's trickier to use distance. You would probably need to identify them using instance variables or something like that.

    I'll play around with your capx and see how I can help out.

  • Thanks for the help MakubeX :)

    In the meantime, I'll carry on trying to get it working the way I want.

  • Blacksmith, I've almost got it, but there's some behavior I don't understand. Maybe Ashley can help here.

    Ashley could you answer the following about the capx I linked below:

    1. Why some sprites start moving again out of order of they're suppose to be sorted in the Foreach?

    2. Why do they flip right after spawning (sprite font pinned flips to the bottom)?

    3. Why do some sprites keep creeping up a little bit after they are supposed to have stopped?

    PS. Press W to stop/start the sprites.

    capx Link

  • MakubeX,

    Thank you for the modified example, I appreciate the effort you've put into helping with my problem :)

    I used a Foreach loop in my first effort too! But I couldn't get it to work the way I thought it should either, so I removed it.

    Not sure why some sprites move out of order with the rest. But that's another problem I encountered when I created the example using stop sprites.

    I'll keep trying to find some answers, and hopefully I can get things working the way they should!

    Thanks again for the help.    <img src="smileys/smiley20.gif" border="0" align="middle" />

  • Ashley - Don't mean to bother you, but the questions in my previous post are eating at me! <img src="smileys/smiley26.gif" border="0" align="middle" />

  • Here's another alternative with the new Timer behaviour, and a few other alterations.

    StopSprite_timers.capx

    (r138.2)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice example blackhornet, it works well.

    I haven't used the Timer behaviour yet, so I didn't think to try it!

    Thanks for the help :)

  • Nice. I tried using the Timer behavior before in a similar manner I did with the Foreach and Wait combo but I had the same problem where when the sprites started moving again after stopping some would start up in the wrong order. I still don't understand why.

  • MakubeX,

    Yeah I know what you mean. It can be very frustrating when it seems as if something should work a certain way but it doesn't! I've had quite a few of those occasions myself.

    Nice to know that there are so many friendly people on hand to help out though! So thanks a lot for all of the help :)

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