Fade In

For questions about using Classic.

Post » Sun Jan 25, 2009 11:52 pm

Hello,

I would like my object to fade into existence, but not disappear once it is done fading. Setting the 'fadeout' and 'wait' times to zero still makes it disappear.

This is for a dialog frame to appear by fading in (within half a second), then I can click it and make it fade away (which would be fade-out behavior, which is quite simple to implement, unlike the fade-in).

Any ideas?
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Jan 26, 2009 12:04 am

Uncheck "Activate at start", and Destroy afterward".
Since your fade in is pretty much instant, set the on click to start fade.
After that you can do an on fade finished in a sub or other event.
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Mon Jan 26, 2009 12:14 am

It fades in no problem, the problem is that it always disappears after that no matter what I do. If I do the 'on fade in finished" subevent, it keeps fading in, which is rather annoying.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Jan 26, 2009 12:47 am

Instead of using the fade behavior, you could just do this:

+If Object Opacity is Less than 0
-Set Object Opacity to Object.Opacity + 100 * TimeDelta

You can change the 100 to anything you want, but that will make it fade in in exactly a second.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Mon Jan 26, 2009 8:24 am

[quote="Mipey":160xd4f0]It fades in no problem, the problem is that it always disappears after that no matter what I do.[/quote:160xd4f0]
Oops, that was a bug. If you disabled the 'Destroy afterwards' option it didn't destroy but left it invisible. Fixed in next build.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,574

Post » Mon Jan 26, 2009 2:39 pm

[quote="linkman2004":25z3cgad]Instead of using the fade behavior, you could just do this:

+If Object Opacity is Less than 0
-Set Object Opacity to Object.Opacity + 100 * TimeDelta

You can change the 100 to anything you want, but that will make it fade in in exactly a second.[/quote:25z3cgad]
That doesn't seem to work, neither do I understand how is it supposed to work. Opacity is 0-100, how can it be less than 0?

Anyway, I've also tried the "on fade in finished" subevent, however that just causes it to loop, no matter the action.

Edit: I've made it work now with this:
[code:25z3cgad]
+On Start of Layout
>MyObject make Invisible
>My Object set Opacity to 0

+On Left Either single or double clicked on MyObject
> MyObject make Visible

+On Right mouse button Either single or double clicked
> MyObject FadeOut
++FadeOut Finished
>> MyObject make Invisible

+ MyObject Is visible
+ MyObject Opacity Less than 100
> MyObject Set opacity to MyObject.Opacity+100*TimeDelta
[/code:25z3cgad]

Bit clunky, but it works: on click the object is made visible, which makes it fade in. On right click I make it fade out using the Fade behavior, then after it is done, it is set to Invisible (otherwise it just loops). So, whenever the object is made visible, it fades in. I don't know, this seems a bit complicated, plus it keeps checking for the condition instead of just executing it once.

Surely there is a more elegant solution? We'll see after I get back from visiting mom - she's down with flu. :?

Thanks for the help so far!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Jan 26, 2009 2:58 pm

i got same problem some time ago
and i just set "wait time" to 1000000000000 - you know many zero's
it's kind'a cheating but well...works :D

Edit:
but anyway i think setting "wait time" to -1 should make it stay forever - just little feature request
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Jan 26, 2009 7:06 pm

Blah, sorry. That should actually be less than 100, not 0. :P Also, to fade in within half a second, change the code to this:

+If Object Opacity is Less than 100
-Set Object Opacity to Object.Opacity + 200 * TimeDelta
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests