D
diester
Guest
Good evening, I still need your knowledge.
I created a life bar and would like to have it flashing at a certain percentage.
what I did, a bar life with the value 40 (which is the max of life).
I then try to apply a flash when the bar reaches 10 of life.
the problem is that it flashing when it is 40 ( max life) .
here is the main code to make it flashing:
creat :
step :
alerte 2 :
alerte 3 :
draw :
sorry for my english i use translator
I created a life bar and would like to have it flashing at a certain percentage.
what I did, a bar life with the value 40 (which is the max of life).
I then try to apply a flash when the bar reaches 10 of life.
the problem is that it flashing when it is 40 ( max life) .
here is the main code to make it flashing:
creat :
Code:
draw_health_ = 0;
flash = 0;
Code:
if (!variable_instance_exists(id, "max_health_")) max_health_ = 40;
max_health_ =- real(10);
alarm[1] = game_get_speed(gamespeed_fps);
if(flash = 0)
{
flash = 1;
alarm[2] = room_speed/5;
image_alpha = 0.5;
}
Code:
image_alpha = 1;
alarm[3] = room_speed/5;
Code:
flash = 0;
Code:
draw_self();
if !instance_exists(obj_player) exit;
draw_health_ = lerp(draw_health_, obj_player.health_, .20);
col = merge_color($FF0000FF,$FFFFFF, 0.5)
draw_set_color(col);
draw_rectangle( x+4, y+4, x+126*draw_health_/obj_player.max_health_, y+11, false) ;