Overlays and such

For questions about using Classic.

Post » Mon Jan 11, 2010 11:15 pm

Hi there! :mrgreen:

First of all, let me just say Construct ROCKS. After 10 years of bugs on MMF/TGF/CNC I'm loving this program. Thanks!!

Ok, what I want to know, is if is there any way to put an effect directly to the whole game screen?

I made this little basic game, and put rain on it, and I want a thunder to happen from time to time. The most basic way of doing that, since I come from MMF, is to draw a white block on a layer above the main one, and generate a random number, so when the generated number hits, let's say, 10, the thunder happens.

Also I'm playing with the opacity, so the screen slowly goes back to normal.. but the thing is, just for that, I'd need lots of lines and at least 2 variables.

So, is there any way of using the effects on the whole screen, so I can just overlay it with white, and slowly turn the overlay effect off?

Thanks !

Here's the game (without the thunder)

http://sites.google.com/site/usonic/her ... ects=0&d=1

(also I've been reading around the forums and found that blurry pixelated characters is an common problem, is that correct?)
B
106
S
35
G
36
Posts: 796
Reputation: 24,711

Post » Tue Jan 12, 2010 12:01 am

If you want to fill the screen with white just add a layer with a non-transparent (white) background on top of everything, and adjust its opacity in events. To process a shader on the full screen, create a window-sized Canvas, enable 'grab layout before drawing', and add a shader to the canvas object.

By default Construct uses linear sampling, which is a way of smoothly rotating and stretching sprites, but its well known side effect is pixelly sprites at floating-point positions look slightly blurred. To restore pixelly movement, rotation and stretching, set sampling to Point in application properties.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Jan 12, 2010 12:03 am

[quote="Ashley":3nkblzir]If you want to fill the screen with white just add a layer with a non-transparent (white) background on top of everything, and adjust its opacity in events. To process a shader on the full screen, create a window-sized Canvas, enable 'grab layout before drawing', and add a shader to the canvas object.

By default Construct uses linear sampling, which is a way of smoothly rotating and stretching sprites, but its well known side effect is pixelly sprites at floating-point positions look slightly blurred. To restore pixelly movement, rotation and stretching, set sampling to Point in application properties.[/quote:3nkblzir]

Thanks for the fast response! Going to try that right now.
B
106
S
35
G
36
Posts: 796
Reputation: 24,711

Post » Tue Jan 12, 2010 9:06 am

For fading the object out smoothly, you could use lerp, that way'd you'll only need two events:

[code:1u9pawev]random(x) -> Set LayerOpacity to 100
If LayerOpacity > 0 -> Set LayerOpacity to lerp(LayerOpacity,0,1-0.0001^TimeDelta)[/code:1u9pawev]

The smaller you make the 0.0001 part the faster the fadeout will be. One another way to speed up the fadeout would be to do this:

[code:1u9pawev]Set LayerOpacity to lerp(LayerOpacity,-100,1-0.0001^TimeDelta)[/code:1u9pawev]

By changing the target opacity from 0 to -100 in the lerp you'll speed up the time required to hit 0.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Tue Jan 12, 2010 11:20 am

[quote="Daiz":35yon0z6]For fading the object out smoothly, you could use lerp, that way'd you'll only need two events:

[code:35yon0z6]random(x) -> Set LayerOpacity to 100
If LayerOpacity > 0 -> Set LayerOpacity to lerp(LayerOpacity,0,1-0.0001^TimeDelta)[/code:35yon0z6]

The smaller you make the 0.0001 part the faster the fadeout will be. One another way to speed up the fadeout would be to do this:

[code:35yon0z6]Set LayerOpacity to lerp(LayerOpacity,-100,1-0.0001^TimeDelta)[/code:35yon0z6]

By changing the target opacity from 0 to -100 in the lerp you'll speed up the time required to hit 0.[/quote:35yon0z6]

I get it.. this is much better than the way I was using, thanks !

Just one question, in the part where you said "random(x)", let's say I use "random(10)", does this means that the layer opacity will go to 100 when the random number reaches 9? I don't understand much of the "random" function :mrgreen:

Or should I create an event to generate a random number each 1000ms, and then use "if numer = 9 -> set layer opacity to 100" ?

Thanks again, that was really helpful, the way I was doing it was kinda buggy.
B
106
S
35
G
36
Posts: 796
Reputation: 24,711

Post » Tue Jan 12, 2010 6:16 pm

[quote:25iali9h]I don't understand much of the "random" function :mrgreen: [/quote:25iali9h]


Look at it this way:

If I tell Construct random(6) then every time it reads that it's going to roll a six-sided die. (The numbers on the die are 0, 1, 2, 3, 4, and 5.)

If I tell Construct random(473) then it will roll a 473-sided die.

You can use this for comparisons. [code:25iali9h]System: Compare: random(10) is equal to 1.[/code:25iali9h] Construct will roll every tick, and on every tick that 1 pops up, the event will trigger. I believe this is what Daiz was meaning in his post, he just wrote in shorthand.

You can use it in other expressions too, like actions.

[code:25iali9h]+ Always
-> Sprite: Set X to random(640) + 1[/code:25iali9h]

Every tick the sprite will set it's x position somewhere between 1 (because of the +1) and 640.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests