How do I change effect parameters over time?

  • 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?

  • Something like this works for me. I don't know how different it is from what you're using.

    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[/code:1mvlsp95]
    A variable is used instead of using loopindex below the wait because the wait action doesn't save the value of loopindex.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Something like this works for me. I don't know how different it is from what you're using.

    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[/code:j0v4w6s6]
    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 ...)

  • Make the wait the top action.

  • THAT seems to work.. it's not intuitive in any way, but it does the trick.. thanks!

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

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)