Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I can see the code you posted will just draw the last frame of your kick animation as the for loop in the LoopOnce method loops round all the frames and only draws the last one. This is because draw method is called once for each update. </p> <p>XNA first calls the update method then after it calls draw. So in your update method your setting the current frame of the animation to the max frame, it then goes in to the draw method where you are then drawing the current frame which at this point is the last frame.</p> <p>For this to work you would have to only increment the frame you want to draw by one for each call to update. </p> <p>I don't have XNA on this computer so I cant test this and it probably wont compile without fixing any syntax errors but to give you an idea something like this should do it</p> <pre><code>private void UpdateAttack(KeyboardState current, KeyboardState last, GameTime gameTime) { if (current.IsKeyDown(Keys.S) &amp;&amp; last.IsKeyUp(Keys.S)) { mCurrentState =State.Kicking; currentImageIndex=25; } if(mCurrentState ==State.Kicking) neutralStandingKick(gameTime); } private void neutralStandingKick(GameTime gameTime) { currentImageIndex++; if(currentImageIndex==30) mCurrentStart = State.SomeOtherState; } </code></pre> <p>Remove your draw once method. You'll need to replace State.SomeOtherState with the state its in when the object is not kicking. You'll probably also want to swap the hard coded frame numbers with constants. Your draw method shouldn't need to be changed for this animation to work. Hope this 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.
 

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