My pause game code works but I don't know why [pics]

0 favourites
  • 5 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • I have to set my initial boolean value to true, and I tried it with a numerical global variable but it didn't work, Why does this work but the others didn't? I just want to better understand the process,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you should init your bool to FALSE (unchecked).

    and add another condition to your Pause

    (right-click and set bool cond to inverted)

    EVENT: On Press Enter AND (NOT) is paused
    ACTION: set paused to true
    ACTION: timescale 0
    

    to unpause

    EVENT: On Press Enter AND is paused
    ACTION: set paused to false
    ACTION: timescale 1
    

    don't use Toggle.. it's just confusing.

  • you should init your bool to FALSE (unchecked).

    and add another condition to your Pause

    (right-click and set bool cond to inverted)

    > EVENT: On Press Enter AND (NOT) is paused
    ACTION: set paused to true
    ACTION: timescale 0
    

    to unpause

    > EVENT: On Press Enter AND is paused
    ACTION: set paused to false
    ACTION: timescale 1
    

    don't use Toggle.. it's just confusing.

    I got you, but why doesn't a number global variable work here? (0,1)

  • N0M4D

    the problem is that both blocks of code will run.

    in the first block you check if Enter has been pressed, then set paused to true.

    the next block checks if Enter has been pressed AND if paused is true (which it will be because you just set it to true) and then it will un-pause your game.

    You should use ELSE to make sure both blocks don't run.

    	EVENT: On Press Enter
    		> is paused - set paused false, set timescale 1
    		> ELSE - set paused true, set timescale 0
    

    then I would expect a global variable would work fine...

  • N0M4D

    the problem is that both blocks of code will run.

    in the first block you check if Enter has been pressed, then set paused to true.

    the next block checks if Enter has been pressed AND if paused is true (which it will be because you just set it to true) and then it will un-pause your game.

    You should use ELSE to make sure both blocks don't run.

    > 	EVENT: On Press Enter
    		> is paused - set paused false, set timescale 1
    		> ELSE - set paused true, set timescale 0
    

    then I would expect a global variable would work fine...

    Yeah that worked like a charm! Thanks for your guys help!

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