public void Update(GameTime gameTime) { _CurrentTStepNum++; if (loopCurrentAnimation == true) { if (_CurrentTStepNum == constants.ANIM_FRAME_UPDATE) { // Go to the next frame _AnimFrame++; // (Actually do it) _ClipSheet.X += 32; // Reset our timer _CurrentTStepNum = 0; if (_AnimFrame >= animationFrames[(int)_CurrentAnim]) { _AnimFrame = 0; _ClipSheet.X = (int)animationOffsets[(int)_CurrentAnim].X; _ClipSheet.Y = (int)animationOffsets[(int)_CurrentAnim].Y; } } } else if (loopCurrentAnimation == false) { if (_CurrentTStepNum == constants.ANIM_FRAME_UPDATE_FAST) { if (!stayOnLastFrame) { // Go to the next frame _AnimFrame++; // (Actually do it) _ClipSheet.X += 32; // Reset our timer _CurrentTStepNum = 0; if (_AnimFrame >= animationFrames[(int)_CurrentAnim]) { _AnimFrame = 0; _CurrentAnim = constants.AnimType.STANDING; _ClipSheet.X = (int)animationOffsets[(int)_CurrentAnim].X; _ClipSheet.Y = (int)animationOffsets[(int)_CurrentAnim].Y; loopCurrentAnimation = true; } } else { if (_AnimFrame < (animationFrames[(int)_CurrentAnim] - 1)) { // Go to the next frame _AnimFrame++; // (Actually do it) _ClipSheet.X += 32; // Reset our timer _CurrentTStepNum = 0; } else { isOnLastFrame = true; } } } } }
public void setAnim(constants.AnimType newType) { // Set the new animation type _CurrentAnim = newType; _CurrentTStepNum = 0; // Start the frame over _AnimFrame = 0; // Make sure the clipping rectangle knows whats going on _ClipSheet.X = (int)animationOffsets[(int)_CurrentAnim].X; _ClipSheet.Y = (int)animationOffsets[(int)_CurrentAnim].Y; }