Hi! I try to make a game in AS2, and i want that when i press a direction then my character walks only once and dont walks more. Any idea? Please add your code idea, thanks.
class "Your MC" extends MovieClip { var speed; var once; function onLoad() { speed = 10; once = 0 ; } function onEnterFrame() { if(Key.isDown(Key.RIGHT)&& once == 0) { _x += speed; once += 1; } } }
you need to add four more var and set them all to Zero. then you need to add && "varName" == 0) after "if (Key.isDown(Key.RIGHT)" your new if statement should be if (Key.isDown(Key.RIGHT)&& "varName" == 0)