How do I move sprite X pixels in X seconds?

0 favourites
  • 5 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • All the help, tutorials, examples i've seen deal with moving to mouse, or object, or something else that requires multiple events and/or actions.

    All i need is to move a sprite from:

    X 480, Y 270 to X 480, Y 80 in 1.5 seconds and stop.

    I've tried 8 direction, bullet and other actions that will make it snap to that posititon or toward that position but then it keeps going.

    Thanks for any help on this.

  • LiteTween is an extremely versatile plugin. It can do this easily.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Something like

    Set Player Y to Player.Y+sin(Player.Angle)*distance in pixels/seconds

    Now I'm not sure about the seconds part

    I might completely off as well.

  • You can use the timer behavior, or set up your own timer/counter variable.

    Instance Variables:



    (On Trigger, Object IsMoving=false)

    Start timer for Self.Duration seconds

    Set Object.IsMoving=true

    (Object IsMoving=true)

    Set Object Y position to lerp(270, 80, Self.Timer.CurrentTime/Self.Duration)

    (Object OnTimer)

    Set Object.IsMoving=false

    Set Object Y position to 80

    This does take 3 events though. Recommend also having start position and end position as instance variables, which you set upon triggering the first event

  • Thanks for the replies. This could work.

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