GML Hp system not working

V

Vincent

Guest
Hello! I'm trying to create a hp system that works with the classical hearts, but I've tried, written and re-written the code, and I can't figure out why all the hearts appear empty (subimage 0 in the sprite)

Player's create event
Code:
global.salud = 11
Player's step event
Code:
if (place_meeting (x+1, y, obj_arana))
    {
    global.salud = global.salud - 1
    }
Health object's step event
Code:
image_index = global.salud
Thanks for your time!!
 
F

fxokz

Guest
Hello! I'm trying to create a hp system that works with the classical hearts, but I've tried, written and re-written the code, and I can't figure out why all the hearts appear empty (subimage 0 in the sprite)

Player's create event
Code:
global.salud = 11
Player's step event
Code:
if (place_meeting (x+1, y, obj_arana))
    {
    global.salud = global.salud - 1
    }
Health object's step event
Code:
image_index = global.salud
Thanks for your time!!
Try this:
Code:
image_index = global.salud-1;
in the step event.

image_index starts counting from 0 as shown below:


hope this helps :)
 

Bingdom

Googledom
Your place_meeting will run every step while it's true. You'll need to add a flag variable or some invincibility time if you want to stop losing health constantly.
 
Top