Test if Sprite Stopped Moving

Get help using Construct 2

Post » Fri Dec 09, 2011 11:11 am

Is there a way to test if a sprite has stopped moving...?
B
40
S
14
G
11
Posts: 243
Reputation: 9,427

Post » Fri Dec 09, 2011 11:27 am

Depend if you use a behavior

If you don't you might want to use a behavior

If you can't just explain your situation a bit more
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Dec 09, 2011 12:13 pm

Ok i have a sprite that is fired using a catapult and physics, i want to destroy it after it stops moving, at the moment i have it destroyed after so many seconds.
B
40
S
14
G
11
Posts: 243
Reputation: 9,427

Post » Fri Dec 09, 2011 12:50 pm

With the Physics behavior you have access to X and Y velocity, you just have to check if it's equal to 0. If it is, it means the sprite doesn't move.

Also you might want to check if it's less than a small value. 'Cause it might take time to completely stop. Just test.

Example:
[code]System: Sprite.Physics.VelocityX < 0.01
System: Sprite.Physics.VelocityY < 0.01
   -> Sprite: set moving to false[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Dec 09, 2011 11:51 pm

Thank thats great and helps me alot.
B
40
S
14
G
11
Posts: 243
Reputation: 9,427


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests