Game maker - 图像索引不会改变

Game maker - Image index will not change

我有两个项目,Object_Player 和 Object_Weapon。 Object_Player的精灵可以是三种不同的精灵,Object_Weapon的精灵索引应该根据Object_Player的精灵而变化。 例如,如果 Object_Player 设置为精灵 Sprite_Hero1,则 Object_Weapon 的精灵索引应该是精灵 Sprite_Weapon 中的第一张图像。如果 Object_Player 设置为 sprite Sprite_Hero2,Object_Weapon 的 sprite 索引应该是 sprite Sprite_Weapon.

中的第二张图片

这是更改 Object_Weapon 索引的代码。它位于 Object_Weapon

的创建块中
if (Object_Player.image_index = Sprite_Hero1) sprite_index = 0
if (Object_Player.image_index = Sprite_Hero2) sprite_index = 1
if (Object_Player.image_index = Sprite_Hero3) sprite_index = 2

我认为您混淆了 sprite_indeximage_index。尝试更改:

if (Object_Player.sprite_index = Sprite_Hero1) image_index = 0
if (Object_Player.sprite_index = Sprite_Hero2) image_index = 1
if (Object_Player.sprite_index = Sprite_Hero3) image_index = 2