Problem with variable comparrison

Discussion and feedback on Construct 2

Post » Mon Dec 31, 2012 11:03 pm

Man, this is killing me.

I'm doing a brick style game and when the block count reaches zero it goes to the next level. To make this faster for testing I included a keyboard shortcut of "K" to move to the next level.

Everything is working great, except for Level 4. Construct does not seem to run the code in the compare check, even though it's true.



When it goes to the Level 4 check, nothing happening. I have a text object showing me the the value of Level and it clearly shows 4, but it never changes to 4.1 like the rest.


ArcadEd2013-01-01 03:36:00
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Tue Jan 01, 2013 2:09 am

www.scirra.com/forum/sprite-spawning-at-wrong-time_topic61209_post375747.html

^ The 0.1 rounding problem. Unfortunately 4.1 - 0.1 = 3.9999999999999999.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Tue Jan 01, 2013 3:34 am

I'll check that out, Thanks!

Is this only a problem with 4? Since it works on each of the other numbers in the example.

So it seems to work fine when I subtract .5 instead. Will I run into any problems later with that?ArcadEd2013-01-01 03:48:57
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Tue Jan 01, 2013 8:38 am

Why do you need to subtract from level in such small increments like that?

I reckon you should keep the level value clean by using only integers, and if you need to subtract by decimals or whatever then use a seperate variable.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Tue Jan 01, 2013 6:43 pm

Yeah, I found another way to do it using active/inactive groups and keeping my level an integer. Thanks for the help.
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993


Return to Construct 2 General

Who is online

Users browsing this forum: shinichild, Unconnected and 2 guests