problem with global variable

Get help using Construct 2

Post » Fri Jul 26, 2013 10:27 am

hi everyone i have in my game 2 layers (layout1 and battle), i have in layer1 an enemy with an instance variable called aux that have a string with a number, when you collide with him it will set the global variable(variable3) to the value of aux, i have a text to debug and that shows the value of the global variable, then it will change to the battle layer and, i dont know why, variable3 wont have any value, i need to fix this because i need that value to pass to the battle layer to trigger some events.

here is my capx https://dl.dropboxusercontent.com/u/85479859/dabestgeim.capx

you need to delete the action set variable3 to 12 on start of layout in the event sheet 2 to trigger the bug, i used that to test some functions that i made because of the bug with the global variable

thanks.
B
21
S
4
G
2
Posts: 82
Reputation: 2,012

Post » Fri Jul 26, 2013 10:53 am

In the last event on eventsheet 1 you are resetting all global variables to default. Take that away and the variable will transfer to battle-layout.

Why is global variable 3 set to text instead of number?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 26, 2013 11:03 am

lol thanks i didnt saw that xD, well that is a text because i need to read for example this 1234, in my game that numbers are different types of enemies, so i need to separate that number in 1 2 3 4 to spawn them in the battle layer, i thought that using a text variable and the functions left() mid() and right() to cut the number would work, and it does.
B
21
S
4
G
2
Posts: 82
Reputation: 2,012


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests