conman06
Member
Ok, so I'm making a game in which you click the trees, then they give you wood. I need to make an object to show how much wood the player has.
In the tree object, I have these scripts for the Global Variable "Wood":
In the WoodIcon object, the scripts are:
But, when I play it, the Wood Icon doesn't change the sprite. That makes me think if there is an error with the Global Variable "Wood"
here is a video of the problem: https://gyazo.com/1f2c2d96bfb091213547bd70073ce3b4
as you can see, when I click the trees, the Wood Icon isn't changing to equal 1.
In the tree object, I have these scripts for the Global Variable "Wood":
GML:
global.Wood = 0;
//When Tree clicked, add +1 wood and disappear.
if (mouse_check_button_pressed(mb_left))
{
global.Wood = global.Wood + 1
visible = false;
}
GML:
if global.Wood > 0
{
sprite_index = sWood1;
}
here is a video of the problem: https://gyazo.com/1f2c2d96bfb091213547bd70073ce3b4
as you can see, when I click the trees, the Wood Icon isn't changing to equal 1.