flash - How to stop a function through another one in AS3? -
so, i'm in flash cs5 file , want disable function when running. more precise: i'm doing function makes me control game character through keyboards. when character hits one, want stop moving, if try press keys again. code:
stage.addeventlistener(keyboardevent.key_down, move) stage.addeventlistener(event.enter_frame, game) function game(e:keyboardevent) : void { if (e.keycode == 39){ character.x += 15; } if (e.keycode == 37){ character.x -= 15; } } function game(e:event): void { if(character.hittestobject(wall)) { **how disable move event here??** } }
i swear i've searched lot! hates bother ;)
var canwalk:boolean = true; function game(e:keyboardevent) : void { if (e.keycode == 39 && canwalk){ character.x += 15; } if (e.keycode == 37 && canwalk){ character.x -= 15; } } function game(e:event): void { if(character.hittestobject(wall)) { canwalk = false; } }
you have switch 'true' once hitaction over.
Comments
Post a Comment