Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like you have not even attempted to try and do the attack animations...at least from what I see in your code. It would be helpful to learn if you at least tried on your own, and then posted, but with that said, I'll give you some starting points. Also, I'm not sure if you're using a document class and other classes to make this game, or if you are just using the timeline.....the following will be for using classes. If you aren't using classes...stop now, and go learn what AS3 really is. You never want to code on the timeline in AS3 if possible. </p> <p>Let's say we have 3 attacks, consisting of the keys "1", "2", and "3". Put these variables up top with your other variables...right after your <code>var LeftDash:Boolean = False</code> is fine. (Also, just change all of your <code>var</code> to <code>private var</code>....if that doesn't work just use <code>public var</code>....just for completeness)</p> <pre><code>private var attack1Boolean:Boolean = false; private var attack2Boolean:Boolean = false; private var attack3Boolean:Boolean = false; </code></pre> <p>Next do pretty much the same thing you do with the keydown and keyup for the arrow keys. Put the following somewhere inside your <code>KeyDown</code> method. </p> <pre><code>if (event.keyCode == 49) { attack1Boolean = true; } if (event.keyCode == 50) { attack2Boolean = true; } if (event.keyCode == 51) { attack3Boolean = true; } </code></pre> <p>and then in your <code>KeyUp</code> method, add the following</p> <pre><code>if (event.keyCode == 49) { attack1Boolean = false; } if (event.keyCode == 50) { attack2Boolean = false; } if (event.keyCode == 51) { attack3Boolean = false; } </code></pre> <p>Now you are ready to start implementing the attacks. You say you have created 3 animations for the attacks already. This means each attack should have it's own timeline (you could have all 3 on one timeline, but separated by frames as well, but I wouldn't recommend this). In order to do what you want (finish each animation before the next attack ensues) you will have to utilize <code>gotoAndStop</code> or <code>gotoAndPlay</code>. </p> <p>It is most useful to create a new .as file for each of your animations. If you have all 3 animations combined into one timeline...that's fine just create 1 new .as file instead of 3. Now link them all normally like you would (if you don't know how to do this...once again...go do a real AS3 tutorial...you're getting ahead of yourself). </p> <p>You will have to create an instance of these new class files, so at the top under your vars, put the following (if you name your new classes <code>Animation1</code>, <code>Animation2</code>...etc.)</p> <pre><code>private var animation1:Animation1; private var animation2:Animation2; private var animation3:Animation3; </code></pre> <p>Then in function <code>Player</code> put</p> <pre><code>animation1 = new Animation1(); animation2 = new Animation2(); animation3 = new Animation3(); </code></pre> <p>Now your animations should be ready to use. Go to your <code>Update</code> method and add the following</p> <pre><code>//note, the animation1.currentFrame == 1 doesn't have to be 1...it's just the initial starting frame of the animation if (attack1Boolean &amp;&amp; animation1.currentFrame == 1 &amp;&amp; animation2.currentFrame == 1 &amp;&amp; animation3.currentFrame == 1) { animation1.x = //character.x if you have a class...this.x for yours animation1.y = //character.y if you have a class...this.y for yours addChild(animation1); attack1Boolean = false; if (animation1.currentFrame = //the last frame of animation1...a number) { animation1.gotoAndStop(1); removeChild(animation1); } } if (attack2Boolean &amp;&amp; animation1.currentFrame == 1 &amp;&amp; animation2.currentFrame == 1 &amp;&amp; animation3.currentFrame == 1) { animation2.x = //character.x if you have a class...this.x for yours animation2.y = //character.y if you have a class...this.y for yours addChild(animation2); attack2Boolean = false; if (animation2.currentFrame = //the last frame of animation2...a number) { animation2.gotoAndStop(1); removeChild(animation2); } } if (attack3Boolean &amp;&amp; animation1.currentFrame == 1 &amp;&amp; animation2.currentFrame == 1 &amp;&amp; animation3.currentFrame == 1) { animation3.x = //character.x if you have a class...this.x for yours animation3.y = //character.y if you have a class...this.y for yours addChild(animation3); attack3Boolean = false; animation3.gotoAndStop(1); if (animation3.currentFrame = //the last frame of animation3...a number) { animation3.gotoAndStop(1); removeChild(animation3); } } </code></pre> <p>That should start the character animation and make it so we can only use one attack once the others are finished. Also, since the condition that the animation must be on it's own frame 1 to begin pretty much also fixed the problem with holding down the key and repeatedly starting the animation (although, you can just continuously hold down the key and it will start the attack over once the animation is complete, but I don't think that's a big problem...if it is let me know). </p> <p>Try all of this, tell me how many bugs there are because I did this from memory, up vote if it helps, =). </p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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