How do I do a smooth flickering light source

Get help using Construct 2

Post » Wed May 21, 2014 12:33 am

Using the LIGHTING example that comes with C2 I've managed to create a flickering lightsource around my player (top-down view) by randomly setting the scale of the light sprite "random(0.9,1.1)", which works, but the lighted area 'jumps' as the scale changes. Is there a way to scale smoothly instead of just jumping from one scale size to another?

You can see what I mean here: http://www.madladdesigns.co.uk/relmquest - use cursor / arrow keys to move. :)
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Wed May 21, 2014 5:20 am

There are a lot of ways you could do this. A couple are as follows:

1 - Use the lerp function to adjust the size of the sprite between it's current size and it's new size. This will create an ease in effect meaning the size change will slow down is it nears the target size.
2 - Simply adjust the size by an increment when the current size and new size are different. This will create a linear change meaning the image will scale at a constant speed.

See the attached capx for an example of both these methods. Of course both are very simple and need some tweaking to get a natural looking flicker but they should at least get you to a starting point.
You do not have the required permissions to view the files attached to this post.
B
38
S
12
G
11
Posts: 331
Reputation: 7,712

Post » Wed May 21, 2014 11:52 am

Thanks. :)
B
72
S
25
G
9
Posts: 383
Reputation: 10,661


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 4 guests