Restart a layout when player dies

This forum is currently in read-only mode.
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • The wiki says that if you do a transition to the current layout you get a restart. I have a global variable called curlevel that starts at 0 and goes up 1 every time the player hits a checkpoint that teleports them to the next level. When the player dies by hitting a wall or enemy they play an animation and when that is finished I wait and then go to layout global(curlevel). The problem I'm having is that when the player hits a wall in the last level it crashes.

    Is there an easier way to implement this? Is there a way to specify current level rather than a number in the transition function.

    .cap is here:

    http://dl.dropbox.com/u/22863144/sailboatgame.cap

  • Can't look into your cap, it sounds like something may go wrong with the counter.

    However, there is no easier way then using 'go to layout'. You are not forced to use numbers, though. If you name your layouts, you can use the names as strings as well. If a layout is called 'uberlevel' then you'd call it with

    go to layout "uberlevel"

  • Try 'Debug all' and watch the value of 'curlevel' to see if it is what you expect. I find debug invaluable for seeing what value is actually being set, compared to what you expect it to be.

  • I checked and the currentlvl value starts at 0 then is set to 2 after the first level, then 4 on the second level, maybe thats the reason

  • Yes, that will be it.

    The first layout has the number 1, if you would have a total of 3 layouts, then number 3 is the highest number you can go to.

    The problem of counting 2x per level could be that the condition for counting up ist still true when entering the new level. Unfortunately, my pc is broken-down, and this 11-year old antique computer I have to use until my pc is repaired refuses to install Construct, so I can't look into the cap.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Instead of using a global to keep track of what the current level, you could just use the system expression "LayoutNumber" to get the current level.

  • Thanks ROJOhound, that's fixed it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)