Restart Layout with number of lives

For questions about using Classic.

Post » Sat Sep 24, 2011 7:19 pm

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.
B
5
G
1
Posts: 20
Reputation: 701

Post » Sat Sep 24, 2011 7:41 pm

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.
B
90
S
32
G
14
Posts: 935
Reputation: 14,540

Post » Sat Sep 24, 2011 7:56 pm

Thanks by the fast reply. =]

No lucky here =Z

This is what I did.
B
5
G
1
Posts: 20
Reputation: 701

Post » Sun Sep 25, 2011 4:40 am

Try running Debugger to see exactly what the problem is.

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

Or does it work both ways?
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Sun Sep 25, 2011 3:34 pm

Looks a progress.
Well as 'Text' the Global Variable is not working.
As Number, yes:

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

Any idea?
Thanks again.
B
5
G
1
Posts: 20
Reputation: 701

Post » Sun Sep 25, 2011 4:58 pm

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 :)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Sep 25, 2011 5:29 pm

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.
B
5
G
1
Posts: 20
Reputation: 701

Post » Sun Sep 25, 2011 5:35 pm

Please don't apologize. There is no need to! This is the help forum - where if not here could one ask for help?
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests