• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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