0
我失去了什麼這裏我雪碧心不是畫在屏幕上XNA
Sprite類
private Texture2D m_tex;
public Rectangle rect;
private bool m_travellingRight;
private int x_pos;
//constructor
public LightSaber(Texture2D tex, int xpos, int ypos)
{
m_tex = tex;
rect = new Rectangle(xpos, ypos, m_tex.Width, m_tex.Height);
m_travellingRight = true;
}
public void drawme(SpriteBatch sb)
{
if (m_travellingRight)
sb.Draw(m_tex, rect, Color.White);
else
sb.Draw(m_tex, rect, null, Color.White, 0, Vector2.Zero, SpriteEffects.FlipHorizontally, 0);
}
public void updateme(GamePadState pad)
{
x_pos = rect.X;
if (pad.ThumbSticks.Left.X < 0 && x_pos > 0)
{
m_travellingRight = false;
rect.X -= 4;
}
else if (pad.ThumbSticks.Left.X > 0 && x_pos < 800 - rect.Width)
{
m_travellingRight = true;
rect.X += 4;
}
}
}
}
的Game1:
LightSaber lightSaber;
lightSaber = new LightSaber(Content.Load<Texture2D>("Textures\\Lightsaber"), 300, 500);
lightSaber.drawme(spriteBatch);
感謝您的幫助。
其C#是的哈哈我的錯誤 – LawrenceB