Screen Flash White

This forum is currently in read-only mode.
From the Asset Store
A collection of 10 amazing sprite sheet animations for your incredible games
  • I'm trying to do a quick flash of white that covers the entire screen...

    My solution so far has been to make a layer that is all white and turn it to invisible by default.

    Then, when I need it to flash I turn it on...

    Turning it back off is the problem.

    I want it to stay on for just a moment -- 25 or 50 milliseconds. The way I have it now (totally lame) is I have an Always event running every 25 milliseconds that just turns the layer invisible. This sort of works, but sometime the flash doesn't show up (clearly a timing issue).

    I realize this is clearly not the correct way to do this -- and my guess is the answer to this is really simple and obvious -- but for the life of me, I can't figure out how it's supposed to work... Is there the equivalent of a "turn on/wait 25 milliseconds/then turn off." command?

    Also, if this runs at 60 frames a second, aren't I going to get different length flashes than if I'm running at 85 frames a second?

  • Make a little white sprite, with a private variable for its opacity time.

    Now with a start of layout event set the sprite to 0,0, set its width and height to the screen.(not necessary, just tidier for your layout.)

    private variable being 0 set the opacity to 0.

    If the pv is greater than 0

    -set opacity to 100

    -set pv to clamp(whitesprite.value('privatevariable') - 100 * timedelta, 0, 100)

    Now, when you want to trigger the flash set the pv to 10 or so.

  • Make a little white sprite, with a private variable for its opacity time.

    Now with a start of layout event set the sprite to 0,0, set its width and height to the screen.(not necessary, just tidier for your layout.)

    private variable being 0 set the opacity to 0.

    If the pv is greater than 0

    -set opacity to 100

    -set pv to clamp(whitesprite.value('privatevariable') - 100 * timedelta, 0, 100)

    Now, when you want to trigger the flash set the pv to 10 or so.

    Cool thanks!

    I did this exactly, except I kept using the all-white-layer-visibility for the flash itself. I tried the sprite stretched across the screen and then set to 0 opacity -- but it seemed to drop the frames per second more than using the layer version.

    Either way, thanks for the timer code. That'll be really useful in a bunch of places!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The gradient object has a built in timer.

  • Did you stretch it across the whole layout or the just the display? If you set it to the size of the displayed area, and have it on a layer that is set to 0,0 for the scroll x/y rate, then it should be quite efficient.

  • Did you stretch it across the whole layout or the just the display? If you set it to the size of the displayed area, and have it on a layer that is set to 0,0 for the scroll x/y rate, then it should be quite efficient.

    The display area and layout are the same on this project. 1920x1080.

    I'll check the scroll x/y rate and see if that helps. Thanks.

    The gradient object has a built in timer.

    I'll try it that way... Didn't know that!

  • The sprite object also has a "flash" action :

    -> Sprite: Flash for 0.5 seconds with 0.1 seconds interval

    EDIT : And the "on flash finished" event that goes with it.

    Dunno if it'll slow down everything though.

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