How do I change effect parameters over time?

Get help using Construct 2

Post » Tue Feb 21, 2017 4:25 pm

Let's assume I have set an effect - BlurHorizontal in this case - for an object. It's set at 100 percent for this object via settings.

I want to decrease the effect over time, right after (or at) the start of the current layout.. so something
like a "fade in" effect (yes I know there's a behaviour which is already very similar.. but let's ignore this for the sake of the question here).

I tried several methods.. using the "On start of layout" event, the "On Loader Layout Complete" event... in combination with
"for" and "repeat" loops and "wait" commands and decreasing the value of BlurHorizontal within this loop .. and yes, already having the "wait issue in loops" in mind ..

https://www.scirra.com/tutorials/723/us ... t-in-loops

.. but.. to no avail.

The loop is finished instantly as it seems, but I DID use "wait * loopindex" method which is mentioned
in the link above.

The only way I can implement the feature is via "System->on every tick" in combination with a simple "wait x seconds" action and some other simple conditions (in order to avoid the effect to be continued
indefinitely). This works like a charm. ("every X seconds" works too)

But I don't think it's very effective.. I don't like the "on every tick" approach.. and I don't get why it's not working with the loop in the "On start of layout" event in the first place.

It doesn't help finding the root cause that I can't set a breakpoint because this is a triggered event... (speaking of breakpoints, they seem of very limited use in Construct anyway because of the limitations.. how are YOU guys
using the debugger in practice?).

Any ideas?
B
16
S
6
Posts: 26
Reputation: 1,221

Post » Tue Feb 21, 2017 4:51 pm

Something like this works for me. I don't know how different it is from what you're using.
Code: Select all
start of layout
   local number value=0
   repeat 10 times
      wait 0.1*loopindex seconds
     add 10 to value
     sprite: set effect "tint" parameter 0 to value

A variable is used instead of using loopindex below the wait because the wait action doesn't save the value of loopindex.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Tue Feb 21, 2017 5:06 pm

Yup R0j0 has a very good solution here.
In one of my games also I wanted better control over the ranges of a sine value so I used another variable to fit my needs.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Fri Feb 24, 2017 10:18 am

R0J0hound wrote:Something like this works for me. I don't know how different it is from what you're using.
Code: Select all
start of layout
   local number value=0
   repeat 10 times
      wait 0.1*loopindex seconds
     add 10 to value
     sprite: set effect "tint" parameter 0 to value

A variable is used instead of using loopindex below the wait because the wait action doesn't save the value of loopindex.


Sorry, it took a while for me to answer..

Hmm.. I just don't seem to get it.. this is my code (it's a sub-event of "start of layout"), doesn't work for me, it doesn't change the value of the blur parameter at all
(..sorry, imagebucket link, you may have to click to get the full size image and I don't know what evil things they're doing at imagebucket ad-wise..
guess I'll have to set up some of my Dropbox or OneDrive folders for public access for future images here ...)

Image
B
16
S
6
Posts: 26
Reputation: 1,221

Post » Fri Feb 24, 2017 11:33 am

Make the wait the top action.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Fri Feb 24, 2017 12:33 pm

THAT seems to work.. it's not intuitive in any way, but it does the trick.. thanks!
B
16
S
6
Posts: 26
Reputation: 1,221

Post » Fri Feb 24, 2017 5:03 pm

Why is it not intuitive? If you set the effect parameter before the wait it would be done then in the event.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Sat Feb 25, 2017 8:56 am

R0J0hound wrote:Why is it not intuitive? If you set the effect parameter before the wait it would be done then in the event.


Well, depends on the way you're looking at it.. after reading the article about the loop and the wait stuff several times I could see why the wait has to be on top... you've really to get your head around the fact that every iteration of the loop starts more or less immediately, and a wait at the end (or in another wrong place) wouldn't help much because all iterations are done almost instantly before getting to the wait command. I know that this is adressed in the tutorial, but as I said, REALLY understanding this is something different.. coming from other programming languages / engines , I have a hard time understanding the concept of Construct sometimes... but I'll get used to it.

I think I got it now.. thanks again!
B
16
S
6
Posts: 26
Reputation: 1,221


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests