How do I have an object continuously fade out and in?

Get help using Construct 2

Post » Wed Oct 15, 2014 2:28 pm

Hello Scirra forums!

I want an object to fade out, then in, continuously on a loop forever till I tell it not to. I want it to happen as soon as the layout starts.
Can this be done with the fade behavior? If not how can I do it?

I have added the 'Start fade' and 'restart fade' and this has the desired effect, but this way I don't see how I could get it to go on forever. Also, I can't seem to get it to repeat after the first restart fade anyway. I'm not sure if I will have to use animations? I see there is a loop feature on a system event, not sure if this is a way to do it.

Thanks!
Sarah
B
3
Posts: 3
Reputation: 181

Post » Wed Oct 15, 2014 2:57 pm

There's many ways to do that, but if you want to use fade behavior then:

Set Fade in to 1, set fade out to 1, set destroy to no.

in events add "Sprite| On fade-out finished - > Sprite| Fade: restart fade
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Wed Oct 15, 2014 3:16 pm

Wow thank you so much! Seems so simple now. I didn't think to add an event directly for the sprite.
B
3
Posts: 3
Reputation: 181

Post » Wed Oct 15, 2014 3:31 pm

Just use sine behavior - opacity.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Wed Oct 15, 2014 4:11 pm

I use opacity with a variable and incrementally count up and down as required... Then compare that variable to start it or stop it at the exact time I want...

Works well with scaling - One thing I did recently was to make a health icon, shaped like a heart and sort of beats like one too...
B
11
S
2
Posts: 46
Reputation: 739

Post » Wed Oct 15, 2014 5:01 pm

I would use an animation for this. The calculations for continually running a fade behavior is cumbersome to a mobile device. If you aren't targeting mobile then never mind.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Wed Oct 15, 2014 6:22 pm

@Tekniko
I'm doing this for a project at uni which is about creating a UI for a mobile game, so it will never be truly implemented so it doesn't really matter. :)

@maxxscape & @A0Nasser
About this opacity with a variable - I am very new to Construct so I'm quite lost in your explanations.

Edit: I was playing around with a variable and opacity but I don't really get how I can use it to fade. If you set opacity from 0 to 100 doesn't that mean I'll have to set it to every number all the way from 0 to 100? :S
B
3
Posts: 3
Reputation: 181

Post » Wed Oct 15, 2014 9:27 pm

This shows scaling but it would work the same with opacity... Might not be the best way, or even the right way but it worked for what I was looking for at the time :D

Image
B
11
S
2
Posts: 46
Reputation: 739


Return to How do I....?

Who is online

Users browsing this forum: Euduardo, Kin, mikehive, ratboy3, tinhofiel, Yahoo [Bot] and 31 guests