test if a sprite has stopped moving

Get help using Construct 2

Post » Sun Oct 09, 2011 1:39 am

How to i set a condition to test if a sprite has stopped moving...


What i'm doing is testing variables e.g.

if ammo = 0
and score < 100
and sprites have stopped moving

display (visible) sorry you need 100 to goto next level.

All works apart from the sprite hasn't stopped moving before text is displayed, BUT the sprite may make that 100th point you need to finish level as it's bouncing about still. So the conditions need to be met after sprite is still.
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Sun Oct 09, 2011 11:08 am

You should post a capx.
Your first post description is pretty much obscure to me though, sorry. Maybe you want to rephrase it a bit to make it more explicit.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sun Oct 09, 2011 11:49 am

Ok say you have 10 balls and your gonna throw them 1 at a time into a hole, and to complete the level you need to get 5 of them in the hole.

So there you go throwing them 1 at a time and after you have thrown 9 balls you have got 4 in the hole so you need to get the last one in,

and in your code you have if Ball = 0 and Score < 5 then it's game over,
and if Ball = 0 and Score => 5 the you won.

What happens is as soon as you throw the last ball, the ball count variable is now 0 so it's game over, BUT your ball is still bouncing around and may go in the hole, so you need this to be game over after the balls stop movingtonycrew2011-10-09 11:51:12
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Sun Oct 09, 2011 1:18 pm

The usual way to see if an object has stopped is to test if its speed equals 0.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Oct 09, 2011 2:02 pm

Ah thankyou... but i don't have a speed.... The ball is using physics and i can't see any speed settings.
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Sun Oct 09, 2011 2:21 pm

Expressions
Sprite.Physics.VelocityX (The X component of the object's speed in pixel per second)
Sprite.Physics.VelocityY (The Y component of the object's speed in pixel per second)
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sun Oct 09, 2011 6:28 pm

[QUOTE=tonycrew] Ok say you have 10 balls and your gonna throw them 1 at a time into a hole, and to complete the level you need to get 5 of them in the hole.

So there you go throwing them 1 at a time and after you have thrown 9 balls you have got 4 in the hole so you need to get the last one in,

and in your code you have if Ball = 0 and Score < 5 then it's game over,
and if Ball = 0 and Score => 5 the you won.

What happens is as soon as you throw the last ball, the ball count variable is now 0 so it's game over, BUT your ball is still bouncing around and may go in the hole, so you need this to be game over after the balls stop moving[/QUOTE]
I think this is related to this game.

Depending on how you coded the game, you might use the wait action (like once you fired the last ball (ball=0) wait 10 secs before checking Score).Kyatric2011-10-09 18:28:35
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sun Oct 09, 2011 10:19 pm

Yeh it's related... Thanks i'll try that in my next update..
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Tue Oct 18, 2011 9:22 pm

Where do the balls go if they miss? Like in bowling, do they go in the gutter and ultimately roll to the back?

Maybe add the ones that make it into the hole with the ones that go in the gutter.

If hole+gutter = 10

then run your win/lose script

That's my suggestion.
B
22
S
9
G
3
Posts: 203
Reputation: 3,647


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests