Stop and start sprites in an orderly line

Get help using Construct 2

Post » Sat Jul 06, 2013 9:06 pm

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 :)
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Mon Jul 08, 2013 6:52 pm

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 :)
Blacksmith2013-07-08 18:52:56
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Tue Jul 09, 2013 12:01 pm

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
B
14
S
6
G
4
Posts: 107
Reputation: 4,858

Post » Tue Jul 09, 2013 1:42 pm

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.    

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

B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Wed Jul 10, 2013 1:19 pm

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.
B
12
S
3
G
3
Posts: 36
Reputation: 3,048

Post » Wed Jul 10, 2013 4:57 pm

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 :)Blacksmith2013-07-10 16:57:56
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Thu Jul 11, 2013 2:23 am

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.
B
12
S
3
G
3
Posts: 36
Reputation: 3,048

Post » Thu Jul 11, 2013 10:17 am

Thanks for the help @MakubeX :)

In the meantime, I'll carry on trying to get it working the way I want.
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Fri Jul 12, 2013 4:54 am

@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 LinkMakubeX2013-07-12 04:56:28
B
12
S
3
G
3
Posts: 36
Reputation: 3,048

Post » Fri Jul 12, 2013 9:37 am

@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.    
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests