SpriterBetaRuntime/SpriterCharacter.cs
/// <summary>
/// Update the character's animation frames
/// </summary>
/// <param name="time">gametime since the last call to update</param>
Update the character's animation frames
Update the character ' s animation frames
public void Update(GameTime time) {
      if (tic > deltaTime) {
        tic = new System.TimeSpan(0);
        currentFrameIdx++;
        if (currentFrameIdx == character.animations[currentSequence].GetTotalFrames()) {
          currentFrameIdx = 0;
        }
        int msecs = (int)character.animations[currentSequence].GetFrameDuration(currentFrameIdx);
        deltaTime = new System.TimeSpan(0, 0, 0, 0, msecs);
        currentFrame = character.animations[currentSequence].GetFrameIdx(currentFrameIdx);
      }
      tic += time.ElapsedGameTime;
    }
public void Update ( GameTime time ) { if ( tic > deltaTime ) { tic = new System . TimeSpan ( 0 ) ; currentFrameIdx ++ ; if ( currentFrameIdx == character . animations [ currentSequence ] . GetTotalFrames ( ) ) { currentFrameIdx = 0 ; } int msecs = ( int ) character . animations [ currentSequence ] . GetFrameDuration ( currentFrameIdx ) ; deltaTime = new System . TimeSpan ( 0 , 0 , 0 , 0 , msecs ) ; currentFrame = character . animations [ currentSequence ] . GetFrameIdx ( currentFrameIdx ) ; } tic += time . ElapsedGameTime ; }
Update the character's animation frames
Update the character ' s animation frames
// if enough time has passed, update current frame information // technically, this is being calculated incorrectly, we should be updating tic more carefully, // and allowing for multiple frames to pass during a single update // however, at 60fps and typical animation rates, this is fine for now
time
GameTime
gametime since the last call to update
gametime since the last call to update