A weird bug

Get help using Construct 2

Post » Mon Jun 24, 2013 10:59 am

I'm experiencing the strangest bug with C2. It's not anything big, but...
OK, I've got three layouts and I use a global sprite as a transition, having three animations: Default, which is empty (activated when not transitioning), and "FadeIn" and "FadeOut". On the second layout I have a button and when you press it it's supposed to start playing the "FadeIn" animation of the transition sprite, which leads to the third layout. The thing is that this works only when I run my game from the first layout. If I run it directly from the second layout, again - everything works, except one thing: It doesn't activate the "FadeIn" animation. And not only that: While trying to retrieve if I've done anything wrong, I tested printing the animation name on the Chrome console. And guess what - it told me that the animation name that was running at the moment was an empty string. It also told me that the animation had 0 frames and that it's repeating the 0th frame indefinitely. Any idea why?Kurajber2013-06-24 11:00:44
B
10
S
2
G
2
Posts: 29
Reputation: 1,710

Post » Mon Jun 24, 2013 11:10 am

If you really made 3 animations (white, fadeIn and fadeOut), you are storing frames for nothing. Use the "Fade" behavior on your sprite. To be exact, use 2 different "fade" behavior : one for the fadeIn, one for the fadeOut. On start of layout, run the fadeOut. On function "nextLayout", call the fadeIn and use the event on end of fadeIn to trigger the real switch to next layout.

Also, if it works perfectly on the first layout but not when starting on another layout, try to export your project to see how it does. If you preview from the second layout, thinking the sprite would be in a specific state because first layout should have set it that way, the result won't be what you think. Running from start should help test more precisely.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Mon Jun 24, 2013 12:11 pm

Wow, I should pay more attention to behaviours. Thank you, I'll try that now.
B
10
S
2
G
2
Posts: 29
Reputation: 1,710

Post » Mon Jun 24, 2013 1:48 pm

I tried what you told me and I unexpectedly ran to another issue. I made two black sprites, both with Fade behaviours. One for FadeIn (fadein time: 1, fadeout time: 0), the other one for FadeOut (fadein time: 0, fadeout time: 1). The only event there is to choose in the event list is "on fade out finished". On both sprites. There's no "on fade in finished" event. Kurajber2013-06-24 13:51:56
B
10
S
2
G
2
Posts: 29
Reputation: 1,710

Post » Mon Jun 24, 2013 2:17 pm

For this purpose I highly recommend the LightTween plugin. It'll give you much better control from more specific conditions and actions.

Either that, or use the Sine behaviour with specific periods and starting points, but that might be a bit more hassle than it's worth.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606


Return to How do I....?

Who is online

Users browsing this forum: newt and 54 guests