tween a sprites position?

0 favourites
  • 4 posts
From the Asset Store
Calculate parabolic trajectories and tween objects over them.
  • Hi, I want to get a panel to slide in/out from left and right with info.

    E.g. I slide it out using a swipe gesture, then slide it back.

    I have tried lots of ways to do this (including scrolling the whole layout), but currently Im trying with a sprite.

    The question is, how do I say "tween the sprite from this X position to this X position" to show it sliding nicely across the screen and stop in the center?

    Do I need to hand write movement code which fires evey tick, and does the necessary maths and setting of X of sprite?

    Could the bullet behavior be used for this type of animation?

    Ive tried bullet, setting the right info panes angle to 270 and speed to 1000 when I detecte a left swipe, but I cant see any way of stopping it in the middle of the variable width screen. Ive tried stopping when X>=0, but X seems to have no conrespondence to the left coordinate of the window: depedning on how big I make the window X is either off screen or somewhere oncreen. Ive tried various other options, including checking to see if on screen etc and overlapping with an offset, but as I have to use crop mode with manual scaling for various different mobile screen sizes, all of these produce random results depending on the current size of teh browser window. I have no understanding of the relationship between window, layout, canvas and viewport - there does not seem to be any manual entry explaining these concepts unfortunately (e.g. canvas, window and viewport do not appear in the manual at all).

    I dont even know what X refers to when you do an object-Compare X. Is it relative to the window, the layer, the viewport, the screen, or something else?

  • There is many ways to achieve that.

    You could even try easetween - it's really nice and easy to use

    or simple lerp(Start.X, Finish.X, some time)

  • Thanks for that.

    Do you know what X is relative to? This is a really fundamental question, and we dont know the answer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • X position

    Sprite: Set X to lerp(Sprite.X, 150,speed*dt) - will move Sprite 100 pixel horizontaly by "speed*dt" (speed is basically how fast - 2*dt, 10*dt)

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