Restarting level in a puzzle game

Get help using Construct 2

Post » Sun Aug 11, 2013 8:32 am

Hi there,

I have a problem with my very first game with C2. It's a puzzle game and you have to make disappear the cubes on the screen.

In every level I added an object that acts like a button that should restart the layout when clicked if you did it wrong. The problem is that when you click on restart, it does, yes, but inmediately changes to the next layout as if level was finished and I don't know why.

I have a global variable called "cubes_level_01" = 3. And there's an event that leads you to next level:

EVENT:
System - "cubes_level_01" (less or equal to) 0
ACTIONS:
System - Wait 2.0 seconds
System - Go to "level_01_finished" (name of next layout)


If you play, game runs correctly. But if you try at any moment the restart button, it leads you to the next layout. The event for reset is:

EVENT:
Mouse - On left button clicked on "reset_button"
ACTIONS:
System - Restart layout
System - Reset global variables to default


I suppose that the problem is that when you reset level, "cubes_level_01" variable turns automaticaly to zero. It's the only explanation, but I can't find why. Can you help me, please?

Thanks in advance. ikarus2013-08-11 08:35:29
B
9
S
1
Posts: 13
Reputation: 499

Post » Sun Aug 11, 2013 10:52 am

"System - Reset global variables to default"

default is always zero, have and event that goes

"System - "cubes_level_01" (less or equal to) 0"

so when it resets the variables to default it also sets the "cubes_level_01" to 0 so they would have the same effect as completing the level,
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Sun Aug 11, 2013 1:35 pm

Thanks, Backlog, for the answer.

I deleted "reset global variables to default" and changed it into "set "cubes_level_01" to 3 (the initial value of the variable)", but the problem persists.
B
9
S
1
Posts: 13
Reputation: 499

Post » Sun Aug 11, 2013 7:39 pm

I would need to see more of your code sheet.
post a capx or take a screen shot of your event sheet showing as much of the event sheet as possible
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Mon Aug 12, 2013 12:14 pm

I don't know much about this. How can I share with you the capx?
I put it in Google Drive:

https://docs.google.com/file/d/0B4iQP7YxdOIRWDdCYXlTbjNjcFk/edit?usp=sharing

Don't be cruel. It's my first game, and I'm pretty sure the game logic can be made much better (but I don't know how).ikarus2013-08-12 12:14:59
B
9
S
1
Posts: 13
Reputation: 499

Post » Tue Aug 13, 2013 7:39 am

Any suggestions?
B
9
S
1
Posts: 13
Reputation: 499

Post » Tue Aug 13, 2013 10:53 am

I think I got a solution, I added a "On Start of Layout" Event at the top, and added the "cubes_level_01=3" there.
B
230
S
62
G
33
Posts: 902
Reputation: 40,323

Post » Tue Aug 13, 2013 11:48 am

Fixed for you. Set Global Number cubes_level_01 to be Constant (checkbox when double click it)
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Tue Aug 13, 2013 11:52 am

Thanks very much, Paradox and Plinkie. I wouldn't have discovered it by myself.
B
9
S
1
Posts: 13
Reputation: 499

Post » Tue Aug 13, 2013 11:52 am

Actually the above won't work for your game. Sorry, do this :

On left button clicked on reset button > Restart layout, reset global variables to default.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Next

Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, senecaa, unicornspitfire, Yahoo [Bot] and 11 guests