else bug?

New releases and general discussions.

Post » Tue Jul 06, 2010 4:08 pm

I was making some animations and made a condition for it that was:
[code:17ebdfw8]
if(play_death_animation == true)
play appropriate death animation
else
if(moving)
moving animation
else
idle
if(jumping)
jumping animation
if(falling)
falling animation
[/code:17ebdfw8]
However, nothing in that else was being done (and adding a simple event to the top of it didn't affect anything either. I had to invert the original if and then stick the nested ones inside of it to make it work and I thought that was mighty strange and made little sense. Explanation for it?
B
1
G
2
Posts: 3
Reputation: 631

Post » Tue Jul 06, 2010 8:49 pm

When an else event has subevents it will not function, it is a know bug and is on the bug tracker.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Tue Jul 06, 2010 9:54 pm

You can often avoid using sub-events with just several else statements in line, each grouped with another condition. Works just like if-elif-else conditionals, and has worked fine for me in Construct. Something like this should work:

[code:2jd4j6v1]+ if(play_death_animation == true)
-> play appropriate death animation

+ else
+ if walking
-> walking animation

+ else
+ if jumping
-> jumping animation

+ else
+ if falling
-> falling animation

+ else
-> idle animation[/code:2jd4j6v1]
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Wed Jul 07, 2010 8:39 am

After much debugging I worked out what causes the else condition to bugger up when its nesting. It should be fixed for the next version
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Wed Jul 07, 2010 10:25 am

Very cool!
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Wed Jul 07, 2010 8:51 pm

Great to hear, David! That will make a big difference to many users, I'm sure. :)
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Wed Jul 07, 2010 10:55 pm

Thank you so much David!
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 0 guests