tween a sprites position?

Get help using Construct 2

Post » Tue Sep 11, 2012 1:37 pm

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?nutmix2012-09-11 14:33:40
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Tue Sep 11, 2012 3:01 pm

There is many ways to achieve that.
You could even try easetween - it's really nice and easy to use
http://www.scirra.com/forum/behavior-easetween_topic53288.html

or simple lerp(Start.X, Finish.X, some time)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Sep 11, 2012 3:09 pm

Thanks for that.

Do you know what X is relative to? This is a really fundamental question, and we dont know the answer.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Tue Sep 11, 2012 3:19 pm

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)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests