Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get mt character to attack
    primarykey
    data
    text
    <p>I'm trying to create a beat em up game and right now i got my character attacking. I have 3 attack animation so far and works just about. This is what i want, if the player presses the attack button then the character will attack and if the player keeps pressing the attack button it will continue with its attack sequence (Note: I do no want if the player holds down the key, has to be a key press).</p> <p>The problem is if you keep mashing the attack button it attacks but the problem is it goes to the next attack animation as soon as the attack button is down and I don't want that. How can i make it go to the next attack animation once the current attack animation has completely finished instead of jumping to the next frame midway of it's current attack animation. So i want the character to finish its attack and if the player still keys in the attack key it will go to the next attack frame otherwise it will stop. This is what i have done so far</p> <pre><code>package { import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; public class Player extends MovieClip { //Attack variables var Attacking:Boolean = false; var Punches:int = 0; var Punching:Boolean = false; public function Player() { stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed); addEventListener(Event.ENTER_FRAME,Update); } function KeyPressed(event:KeyboardEvent):void { //Note: I need these listeners here stage.removeEventListener(KeyboardEvent.KEY_DOWN, KeyPressed); stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp); //If A key is down if (event.keyCode == 65) { Attacking = true; Punching = true; Punches++; } } function Update(event:Event) { //If player is not attacking if (Attacking == false) { Punching = false; Punches = 0; } else if (Attacking == true) { if (Punching == true) { gotoAndStop('Jab' + Punches); } } } function KeyUp(event:KeyboardEvent) { stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed); } } } </code></pre> <p>Also within the last frame of every attack animation i have put down</p> <pre><code>import flash.display.MovieClip; import flash.events.Event; stop(); MovieClip(parent).Attacking = false; MovieClip(parent).Punches = 0; </code></pre> <p>Not sure if this method is the best way around it or should i create a extended class/arrays if so how will i do this</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload