test if a sprite has stopped moving

0 favourites
  • 9 posts
From the Asset Store
2d mushroom sprite 2d game character enmy sprite game art
  • 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.

  • 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.

  • 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

  • The usual way to see if an object has stopped is to test if its speed equals 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah thankyou... but i don't have a speed.... The ball is using physics and i can't see any speed settings.

  • 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)

  • 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

    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).

  • Yeh it's related... Thanks i'll try that in my next update..

  • 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.

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