How do I Stop My Levels From Randomly Skipping?

Get help using Construct 2

Post » Tue Apr 01, 2014 10:16 pm

Hello all, I was wondering why, from time to time, my levels will skip (only levels 7-10), but other times I'm able to play through the entire game without any problems at all? (Besides this problem) My game's finished and I want to post it soon, but I don't want to post the full game yet. Here's the complete code (it's long, but I had to get it all in if I'm ever going to figure out what the problem is):

Here's an example of the problem I'm having: When I win the 8th level, I'll click the "go to level 9" button, but instead of bringing me to level 9, it will go back to the beginning of level 8. The same thing happens, from time to time, for levels 7-10, but never for levels 1-6 for some reason.

https://dl.dropboxusercontent.com/u/541 ... pture1.PNG
https://dl.dropboxusercontent.com/u/541 ... pture2.PNG
https://dl.dropboxusercontent.com/u/541 ... pture3.PNG
https://dl.dropboxusercontent.com/u/541 ... pture4.PNG
https://dl.dropboxusercontent.com/u/541 ... pture5.PNG
https://dl.dropboxusercontent.com/u/541 ... pture6.PNG
https://dl.dropboxusercontent.com/u/541 ... pture7.PNG

Image
Image
Image
Image
Image
Image
Image

Thanks,
guannstar
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Post » Tue Apr 01, 2014 11:37 pm

To me it looks like a bunch of your level start functions are actually empty functions.
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Wed Apr 02, 2014 12:18 am

What do you mean? Should I delete all of them?
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Post » Wed Apr 02, 2014 12:19 am

Is that the only problem you can see?
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Post » Wed Apr 02, 2014 1:07 am

Honestly, I think I think your code is too long for someone to debug using pictures.

So right now when your program starts it reserves memory for all of those global variables and stores their initial value.
Then it gets to line 1 and says to itself "Okay, I need to update that text with varScore twice every tick"
Then it gets to line 2 it says "This event is true, so lets do the action."
Then it goes down to line 338 and executes that function call. Turning all of those things to invisible. (By the way we can't see any of the object in your actions because the names are hidden in your pictures.)
So after the program does everything in that function it goes back to line 3.
The conditions of the event on line 3 - 11 are all false at this point so it skips them and continues to the next line.

So I assume at some point the conditions of the event on line 5 become true. So it's going to go to line 365 for the function call. But since the function on line 365 is empty it will immediately go back to line 6. So that was basically unneeded code as it is now.

I think I'd start debugging by looking at where you are changing Active_level. It's easy enough to do in C2 by clicking on the Events tab and entering in Active_level in the search field. So you can see exactly where it's used. In your images... not so easy...
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Thu Apr 03, 2014 2:36 am

Bump... So, should I delete all of the empty function calls as well as lines 3-11?
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Post » Thu Apr 03, 2014 3:12 am

Well if the functions are empty you might as well, since they don't do anything anyway. Except 11 because it looks a bit weird, "On start of layout" (Line 12) are link to "Active level 10" (Line 11) What is the reason for it to be link to that only, ain't all the levels the same in regards to the high score or?

But as already mentioned its not easy to debug that much code, but think you could try to make a level tester, in the sense that you make a button or a key, that when you press it advance the level by one, and then you check that the variables that have something to do with switching levels are correct. So run it in the debugger and each time you switch level you go through the relevant variables and check that they are correct.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 4:50 am

@guannstar buddie your code is perfect. i just want to tell you one think
# have you delete the function part of lvl 10 when your were making the code.
# construct2 take some time to update that thing.
# if the bug still persist then i have a quick solution . delete or uncomment on the lvl 10.
# now put againg the lvl 10 code do not copy form lvl 9.
# Export the project and close construct.
# now again import the project from exported folder. this should work. :lol:
B
7
S
1
G
1
Posts: 79
Reputation: 716

Post » Wed Apr 09, 2014 10:11 pm

@samblack Hey, thanks for the help. Can you show me what you mean when you say, "have you delete the function part of lvl 10 when your were making the code."? I don't get it:( Can you show me what you mean?

Thanks again (I really appreciate all the help).
Last edited by guannstar on Thu Apr 10, 2014 5:09 am, edited 3 times in total.
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Post » Thu Apr 10, 2014 2:29 pm

Bump... can someone please help me out with what 'samblack' said above? I'm not sure what he means. Thanks all.
B
39
S
9
G
1
Posts: 632
Reputation: 4,037

Next

Return to How do I....?

Who is online

Users browsing this forum: dereck28, Ryan Kocourek and 20 guests