
I wan to eliminate the upper rectangle part but it always only can eliminate the lower part. How to solve this issue?
sprite:

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Sprite_Animation
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteEffects flip;
Texture2D character;
Vector2 characterPosition = new Vector2(200, 200);
Point currentFrame = new Point(0, 0);
Point frameSize = new Point(156, 100);
//Point sheetSize = new Point(12, 35);
float speed = 15;
//float speed = 30;
bool SWITCH = true;
bool noFrameY = true;
bool WAIT = true;
KeyboardState currentState;
KeyboardState theKeyboardState;
KeyboardState oldKeyboardState;
enum State
{
Walking,
Punch,
Jump,
JumpForward,
JumpBackgwards
}
State mCurrentState = State.Walking;
TimeSpan nextFrameInterval = TimeSpan.FromSeconds((float)1 / 16);
TimeSpan nextFrame;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
//this.graphics.PreferredBackBufferWidth = 1366;
//this.graphics.PreferredBackBufferHeight = 768;
//this.graphics.IsFullScreen = true;
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 110);
TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 77);
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
bool test;
bool move;
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
character = Content.Load<Texture2D>("character2");
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
//bool test;
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
KeyboardState keys = Keyboard.GetState();
currentState = Keyboard.GetState();
theKeyboardState = Keyboard.GetState();
if (currentState.IsKeyDown(Keys.Left))
{
// if it is not currentframe.Y
if (noFrameY)
{
if (WAIT)
{
WAIT = false;
frameSize.Y = 100;
currentFrame.X = 0;
currentFrame.Y = 0;
}
else
currentFrame.X++;
// switch to currentframe.Y
if (currentFrame.X == 3)
{
noFrameY = false;
WAIT = true;
}
}
else
{
// set to currentframe.Y; increse currentframe.X on next loop
if (WAIT)
{
WAIT = false;
frameSize.Y = 105;
currentFrame.X = 0;
currentFrame.Y = 1;
}
else
{
currentFrame.X++;
}
if (currentFrame.X == 3)
{
noFrameY = true;
WAIT = true;
}
}
characterPosition.X -= speed;
flip = SpriteEffects.None;
}
oldKeyboardState = theKeyboardState;
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(character, characterPosition, new Rectangle(
frameSize.X * currentFrame.X,
frameSize.Y * currentFrame.Y,
frameSize.X,
frameSize.Y),
Color.White, 0, Vector2.Zero, 1, flip, 0);
spriteBatch.End();
base.Draw(gameTime);
}
}
}