这是第一个称为hud的对象:
if(global.dead == false){
//Draw health bar
draw_sprite(spr_hearts, global.hp, 10,10)
//Set score
//draw_set_color(c_white)
//draw_set_font(fnt_main)
} else {
draw_text((room_width/2) - 30,room_height/2-30 , "GAME")
draw_text((room_width/2) - 25,room_height/2 , "OVER")
}
这里是第二个,叫做obj_score:
draw_set_color(c_white)
draw_set_font(fnt_score)
draw_text(140,10,"SCORE : " + string(global.score))
答案 0 :(得分:1)
draw_set_font()
,draw_set_colour()
等功能更改图形管线的全局状态。不是每个对象都独立。因此,对象hud
应该类似于:
if !global.dead
{
// Draw health bar
draw_sprite(spr_hearts, global.hp, 10, 10);
}
else
{
draw_set_color(c_white);
draw_set_font(fnt_main);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(room_width div 2, room_height div 2, "GAME#OVER"); // or "GAME\nOVER" for GMS2
}
还有obj_score:
draw_set_color(c_white);
draw_set_font(fnt_score);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
draw_text(140, 10, "SCORE : " + string(global.score));
或者如果您想要一起使用:
draw_set_color(c_white);
draw_set_font(fnt_score);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
draw_text(140, 10, "SCORE : " + string(global.score));
draw_set_font(fnt_main);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(room_width div 2, room_height div 2, "GAME#OVER");