T
thrash
Guest
Hello together,
not sure if I do something wrong or if gamemaker trolls me, but...
I have a global variable named global.towerbuilder and set it to 0 when the room starts with a controller object.
I have some instances of an object in my room, which are places where towers are placeable (in the future), when my cursor object is hitting the tower place object, I set the global.towerbuilder to 1, and when I leave the place object with the cursor I set it back to 0.
The strange thing is, this only happens to the last added instance in the room, the other instances of the place object don't show any reaction.
At first I did this with a instance variable, but I need to acces the variable from other objects and thought a global variable was the best way, and now I'm sitting here, with only few days left (gbjam...) arrrrr.
Heres a .gif where you see my problem: https://www.dropbox.com/s/tu8atszcs07ugoe/globvartest.gif?dl=0
Heres the code of the place objects step event:
Hope you can enlight me... I have no idea and wasted so many hours of trying and figuring out. I set the numbers to 22 and 44 in my example, instead of 0 and 1, in case you are wondering.
thank you.
not sure if I do something wrong or if gamemaker trolls me, but...
I have a global variable named global.towerbuilder and set it to 0 when the room starts with a controller object.
I have some instances of an object in my room, which are places where towers are placeable (in the future), when my cursor object is hitting the tower place object, I set the global.towerbuilder to 1, and when I leave the place object with the cursor I set it back to 0.
The strange thing is, this only happens to the last added instance in the room, the other instances of the place object don't show any reaction.
At first I did this with a instance variable, but I need to acces the variable from other objects and thought a global variable was the best way, and now I'm sitting here, with only few days left (gbjam...) arrrrr.
Heres a .gif where you see my problem: https://www.dropbox.com/s/tu8atszcs07ugoe/globvartest.gif?dl=0
Heres the code of the place objects step event:
Code:
if (place_meeting(x,y, obj_mouse)) {
image_index = 1;
global.towerbuilder = 44;
} else {
image_index = 0;
global.towerbuilder = 22;
}
thank you.