Smoothly expanding sprite

Get help using Construct 2

Post » Sun Nov 23, 2014 10:25 pm

How would you do this? I don't mind how it's implemented as log as it looks good (although bonus points for using standard C2).

Need (on user action):
- a round (disc) sprite expands from 'zero' to say, 130px radius
- must be visually smooth
- must be quick (e.g. no more than 0.3 sec) to fully expand
- must be same speed on any device (this is for mobile)

Thanks!
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Nov 23, 2014 10:48 pm

You can use lerp()

lerpspritesize.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Nov 24, 2014 12:52 am

Thanks for that.. It's smoother than what I had and more consistent. I measure 0.22sec on pc (for comparison) and about 0.28sec on my slowest device.

I added dt to get it the same across devices, and a timer to check. edit: and x4 sprites because I need 4 at once.
lerpspritesize_2.capx


I had been playing with scale and even animation frames. Scale is jumpy and animation frames play back at different speeds on different devices.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Nov 24, 2014 3:07 am

You can set it up a bit different so it will take exactly 0.3 seconds to transition. Then you also could use qarp() or cubic() for a non-linear transition.

Here are some ideas:

ease in:
qarp(0, 130,130, self.t)

ease out:
qarp(0, 0,130, self.t)

Overshoot and fall back:
qarp(0, 200,130, self.t)
You do not have the required permissions to view the files attached to this post.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Mon Nov 24, 2014 3:31 am

Thanks so much, I'd never think to use that. Will be checking it out asap.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: Kin, Yahoo [Bot] and 26 guests