Simple Animation

Get help using Construct 2

Post » Fri Mar 16, 2012 7:42 am

Is there a way to create a simple animation in C2 without using the actual sprite animation?

I just want to make a logo slide from a Y Value to another Y Value.
Pixiefingers2012-03-16 07:52:28
B
11
S
2
Posts: 127
Reputation: 1,532

Post » Fri Mar 16, 2012 9:38 am

Code: Select all
Global number t = 0  //evolution of interpolation (from 0 to 1)
Global number startY = -20 //vertical start position of movement
Global number enY = 300    //vertical end position of movement
Global number speed = 100  //average speed in px per second
System:Every tick
  -> System: set t to min(t+dt*speed/Abs(endY-startY),1)

And then
For a linear movement you use
Code: Select all
System: Every tick
  -> Sprite: set Y to lerp(startY,endY,t)

For an eased-out movement you use
Code: Select all
System: Every tick
  -> Sprite: set Y to lerp(startY,endY,t^2)

For an eased-in movement you use
Code: Select all
System: Every tick
  -> Sprite: set Y to lerp(startY,endY,t^0.5)
Last edited by Yann on Sun Sep 14, 2014 11:18 am, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Mar 16, 2012 10:35 am

thank you
B
11
S
2
Posts: 127
Reputation: 1,532


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests