Restart Layout with number of lives

This forum is currently in read-only mode.
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi, well I had to get back for you again, after hours without any lucky.

    When the character dies I can change the text for one number less, but when the layout restarted it backs to the first number.

    Well, I saw some references for global variables, I created one, but I have no idea how to use it.

    int(.text) - 1

    I found this expression but I think it can be used only in Private Variables.

    No lucky too finding some examples, when I was near from it, the files are missing...

    Any help is appreciated!

    Thanks for now.

  • Make a global variable (you've got that down) with an initial value of 3 or 5 or however many you want. You can then reference this number from any layout.

    So,

    If Player collides with 'kill' --- Subtract 1 from global variable "Lives"

    --- Lifetext: Set text to 'lives'

    Use the single quotes so it knows you're referencing a global variable. Let me know if that makes sense! Then you can do things like

    Is global variable 'lives' Less or equal 0 --- System: Go to layout 'usersucksatthisgame' with transition "None"

    or whatever you'd like!

    Let me know if that made sense.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks by the fast reply. =]

    No lucky here =Z

    <img src="http://dl.dropbox.com/u/31568350/ChickenProblem.jpg" border="0" />

    This is what I did.

  • Try running Debugger to see exactly what the problem is.

    Try doing global('lives') instead of 'lives'.

    Or does it work both ways?

  • Looks a progress.

    Well as 'Text' the Global Variable is not working.

    As Number, yes:

    <img src="http://dl.dropbox.com/u/31568350/ChickenProblem_b.jpg" border="0" />

    But putting the Set Text, it changes to "LIVES" letters, not numbers.

    Any idea?

    Thanks again.

  • Set text doesn't change anything. It just does what you tell it to. You order the text box to set the text to the word "Lives".

    A global variable is adressed with the keyword global.

    Here is a cap showing how you have to do it.

    Also, please have a look at the wiki. It really helps with issues like this one :)

  • Thanks tulamide! And sorry about that!

    I didn't knew about this doc, I have saved it now.

    I'll put more efforts to find my problem next time, idk if my english helps me lol.

    Well, problem SOLVED!

    Thank you all, and sorry again.

  • Please don't apologize. There is no need to! This is the help forum - where if not here could one ask for help? <img src="smileys/smiley1.gif" border="0" align="middle" />

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