我试图在 GM 中使用一种以上的字体,但是在绘制事件中使用 draw_set_font 时,我绘制的两个字体都变得相同,即使我在两个不同的对象中使用 draw_set_font。请,我该怎么做才能解决这个问题?
这是第一个对象,称为 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))
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");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句