Pulsating transparency

For questions about using Classic.

Post » Sat Jul 09, 2011 9:02 pm

Has anyone done a visual effect where an object might slowly have its transparency reduced to zero, then back up to 100%? If so, are there any nice effective ways of going about this? So far, the only thing I can think of is using a variable to determine when to raise or lower the transparency. If transparency = 100, set variable to 1. If variable = 1, reduce transparency every tick. If transparency = 0, set variable to 0. If variable = 0, increase transparency every tick.

Would something like that be my only method of executing an effect like this?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Sat Jul 09, 2011 9:10 pm

You can use Sine behavior to do it easly without any event.
Events hmm:

[code]+ System: Is global variable 'opct' Equal to 0
-> Sprite: Set opacity to Sprite.Opacity-100*TimeDelta
+ System: Is global variable 'opct' Equal to 1
-> Sprite: Set opacity to Sprite.Opacity+100*TimeDelta
+ Sprite: Opacity Equal to 0
-> System: Add 1 to global variable 'opct'
+ Sprite: Opacity Equal to 100
-> System: Set global variable 'opct' to 0
[/code]
or
[code]
+ System: Always (every tick)
-> System: Add 1 to global variable 'opct'
-> Sprite: Set opacity to Sprite.Opacity-sin(global('opct'))
[/code]
shinkan2011-07-09 21:13:38
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Jul 09, 2011 9:54 pm

You can simplify those by using the timer, a built in variable. Other options, you could also use lerp:

always
- set opacity to lerp(0, 100, timer/300)

or use

always
- set opacity to cosp(0, 100, timer/300)

...for a sine wave instead. But yeah, the sine behavior is the easiest.Arima2011-07-09 21:59:59
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sat Jul 09, 2011 10:24 pm

[QUOTE=shinkan] You can use Sine behavior to do it easly without any event.[/QUOTE]

I didn't even know you could do that. Must be a new addition to sine. Neat.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Sat Jul 09, 2011 10:32 pm

[quote] You can simplify those by using the timer, a built in variable. Other options, you could also use lerp:

always
- set opacity to lerp(0, 100, timer/300)

or use

always
- set opacity to cosp(0, 100, timer/300)[/quote]

i don't think construct will ever stop suprising me. Thank you so much for this Arima!
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Jul 09, 2011 10:47 pm

I hear ya. I've been using it since the earliest betas and I'm STILL occasionally surprised by features I didn't know about! XD

BTW Kisai, I think you're right, I recall extra options being added to it a while ago.Arima2011-07-09 22:48:21
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests