Fade in, fade out without changing scenes
Hi. I've been using interpolate to fade actors in and out, then changing scenes. This is fine, but what if I don't want to change scenes?
I start by setting the prototype actor's alpha to zero. Then I create this rule:
When attribute self.color.alpha = 0
Interpolate attribute self.color.alpha to 1
Duration 3 seconds
This makes the actor fade in at the start of the scene.
Then I create this rule:
When actor receives event touch is pressed
Interpolate attribute self.color.alpha to 0
Duration 3 secondsTimer: after 3 seconds
Change scene
This makes the actor fade out and changes the scene.
It works great.
But if I don't change scenes, what occurs is an endless loop of the actor fading in and fading out. This makes sense because every time you click on the actor and the actor's attribute self.color.alpha = 0, then it Interpolates self.color.alpha to 1, duration 3 seconds. Over and over.
Can I get an actor to fade in to start the scene, fade out when clicked, stay faded out, and never have to change scenes?
Thanks.
Comments
Fade in:
Interpolate alpha to 1.
. . . . .
Fade out:
When touch is pressed - Interpolate alpha to 0.
But as I explained above, when touch is pressed and you interpolate alpha to 0, it triggers the first rule:
Which causes the actor to fade right back in.
Interpolate attribute self.color.alpha to 1
Duration 3 seconds
Yes, your code causes the actor to fade back in, so use the code I posted above instead.
Sorry Socks. I'm either explaining myself poorly or I'm not understanding you.
It seems to me that I already am using your code. I thought I was already doing exactly what you were suggesting.
Is my mistake that I'm setting the prototype's alpha to 0? I think what I'm not understanding is what triggers your first rule; the "fade in" rule.
You are doing this:
When attribute self.color.alpha = 0
Interpolate attribute self.color.alpha to 1
Duration 3 seconds_
When actor receives event touch is presse_d
Interpolate attribute self.color.alpha to 0
Duration 3 seconds
. . . . .
I am suggesting this:
Fade in: Interpolate alpha to 1
Fade out: When touch is pressed - Interpolate alpha to 0
. . . . .
There are some pretty obvious differences !?
If you want your actor to start with its alpha set to 0 (invisible) then you should set it to 0.
Nothing ! You don't need to trigger a rule, it will just run when you start the game.
All right. I understand now. I needed to remove my first line:
Thanks for your help.
Yep ! There's no real need for that rule.
Now I want to rediscover the forum post or youtube video that instructed me to include that rule. It should be amended to include the fact that that rule is not needed. I'm still very new to GS so I follow whatever instructions I receive as faithfully as I can.
It might have been needed in the particular scenario the tutorial was explaining ?