How do I make effects apply over time?

Get help using Construct 2

Post » Tue Oct 28, 2014 11:23 am

I want to have an effect to apply itself over time. So for example I want the screen to fully desaturate over 5 seconds or so and later trigger something so it does the reverse. How would I go about doing that?
B
10
S
2
G
1
Posts: 49
Reputation: 693

Post » Tue Oct 28, 2014 12:38 pm

Hey Leaufai, :)

The following might do what you're looking for.
In your layout, place a layer above all your other layers.
Add the "Adjust HSL Mask" effect to this layer. (You can click the layer in the layer panel and edit it's properties in the properties panel.)
Set the layer's "Transparent" property to "No".
You should now be able to post-process the entire game with the "Adjust HSL Mask" effect.


To smoothly fade in an fade out the effect, create two number variables.
"targetSatValue"
"followSatValue"
We'll use these to control the effect's saturation parameter.

In this example, I'll use functions as the triggers for starting and stopping the desaturation effect, but you could use anything you want.

* On function "desatOn": Set "targetSatValue" to 100.
* On function "desatOff": Set "targetSatValue" to 0.
* Every tick, if followSatValue < targetSatValue: Add 1 to "followSatValue".
* Every tick, if followSatValue > targetSatValue: Subtract 1 from "followSatValue".
* Every tick: Set "Adjust HSL Mask" param 1 (the saturation) to "followSatValue".
(Actions in italics.)


When the function "desatOn" is called, the targetSatValue is set to 100, and the followSatValue will begin gradually counting up to the target. When the targetSatValue is set to 0, then followSatValue will count back down to the new target value.

Hope that helps. :)
B
26
S
17
G
8
Posts: 323
Reputation: 6,021

Post » Wed Oct 29, 2014 12:38 am

@leaufai This is actually pretty complicated to do. Check out the CAPX file that comes standard with the Construct 2 download under your example files.
B
13
S
5
G
1
Posts: 119
Reputation: 2,292

Post » Wed Oct 29, 2014 12:39 am

B
13
S
5
G
1
Posts: 119
Reputation: 2,292


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests