Screen Flash White

For questions about using Classic.

Post » Mon Dec 20, 2010 7:47 am

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?
B
4
S
1
G
2
Posts: 64
Reputation: 980

Post » Mon Dec 20, 2010 8:59 am

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Mon Dec 20, 2010 12:05 pm

[quote="Steven":286exb5f]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.[/quote:286exb5f]

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!
B
4
S
1
G
2
Posts: 64
Reputation: 980

Post » Mon Dec 20, 2010 6:20 pm

The gradient object has a built in timer.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Dec 20, 2010 7:14 pm

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Mon Dec 20, 2010 11:22 pm

[quote="Steven":1xbq5g1u]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.[/quote:1xbq5g1u]

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.

[quote="newt":1xbq5g1u]The gradient object has a built in timer.[/quote:1xbq5g1u]

I'll try it that way... Didn't know that!
B
4
S
1
G
2
Posts: 64
Reputation: 980

Post » Tue Dec 21, 2010 10:34 am

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.
B
4
S
1
G
2
Posts: 91
Reputation: 1,057


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests