2016-12-13 18 views
1

我正在製作遊戲製作者v1.4.1763中的迷宮遊戲,並且需要一些基於其移動方向來更改對象精靈的幫助。我目前有一個使用遊戲製作者拖動和移動「移動」動作的鼠標,我從4個不同的角度(前,後,左,右)爲對象製作動畫。對象可以移動任何方向(它不必堅持主要方向)如何根據遊戲製作者在movment上的方向更改gamemaker中的物體精靈?

我想讓對象基於巫婆的方式來改變它的精靈,它是「主要」移動。我真的不知道如何使用遊戲編程但我知道如何讓它執行代碼我已經嘗試了幾乎所有使用拖放編碼的代碼,只能使用一些代碼來完成,如果有人能幫我拿出代碼,那將會很棒。

在此先感謝, 利亞姆

回答

1

最簡單的方法:

if direction > 45 and direction <= 135 and sprite_index != spr_up 
    sprite_index = spr_up; 
else if direction > 135 and direction <= 225 and sprite_index != spr_left 
    sprite_index = spr_left; 
else if direction > 225 and direction <= 315 and sprite_index != spr_down 
    sprite_index = spr_down; 
else if sprite_index != spr_right 
    sprite_index = spr_right; 

spr_leftspr_rightspr_upspr_down是你的精靈。 您可以將此代碼置於Step End事件中。