【GMS2】求教, 武器精灵的绘制问题
gamemaker吧
全部回复
仅看楼主
level 8
逐光Dream 楼主
我打算用draw的方法绘制武器精灵,代码是这样的:
draw_self();
if state == "atk1" {
if (image_index == 0) draw_sprite_ext(wp_1,0,x-2,y-16,1,1,35,image_blend,image_alpha)
if (image_index == 1) draw_sprite_ext(wp_1,1,x+5,y+6,1,1,-90,image_blend,image_alpha)
if (image_index == 2) draw_sprite_ext(wp_1,2,x+2,y+9,1,1,-175,image_blend,image_alpha)
}
wp_1是武器精灵,坐标和武器位置我都测过了,没问题
但是实际运行时,武器精灵一闪一闪的,貌似是中间有几帧没有绘制,如何解决呢?
感谢[乖]
2018年07月09日 07点07分 1
level 8
逐光Dream 楼主

2018年07月09日 08点07分 2
level 9
应为image_index是很多时候不是整数,它可能是0,0.2,1.5之类的。
所以你要加上floor()
if state == "atk1" {
if (floor(image_index) == 0) draw_sprite_ext(wp_1,0,x-2,y-16,1,1,35,image_blend,image_alpha)
if (floor(image_index) == 1) draw_sprite_ext(wp_1,1,x+5,y+6,1,1,-90,image_blend,image_alpha)
if (floor(image_index) == 2) draw_sprite_ext(wp_1,2,x+2,y+9,1,1,-175,image_blend,image_alpha)
}
2018年07月09日 10点07分 3
1