1
我正在XNA製作一個簡單的2人艦船射擊遊戲。Sprites隨機停止繪製XNA 4.0
當我火的時候按住空格鍵的彈精靈繪製,但是當我放開空格鍵和拍攝又是第一個精靈是不是在所有的繪製。
但它仍然在遊戲和功能的意圖,有代碼的問題或有任何解決方案嗎?
protected override void Draw(GameTime gameTime)
{
//Loading and Drawing the background through XNA spriteBatch
spriteBatch.Begin(0, BlendState.AlphaBlend);
spriteBatch.Draw(backgroundTexture, GraphicsDevice.Viewport.Bounds, Color.White);
//Drawing the spaceship on the screen
spriteBatch.Draw(spaceship.sprite, spaceship.position, null, Color.White);
//Drawing the alienship
spriteBatch.Draw(alienship.sprite2, alienship.position2, null, Color.White);
spriteBatch.End();
//Drawing the projectile
spriteBatch.Begin(0, BlendState.AlphaBlend);
if (projectile.alive == true)
{
spriteBatch.Draw(projectile.sprite, projectile.position, Color.White);
}
//Drawing the 3rd Projectile
if(projectile3.alive == true)
{
spriteBatch.Draw(projectile3.sprite, projectile3.position, Color.Red);
}
//Drawing the 4th Projectile
if (projectile4.alive == true)
{
spriteBatch.Draw(projectile4.sprite, projectile4.position, Color.Green);
}
//Drawing the Special Projectile
if (projectile2.alive)
{
spriteBatch.Draw(projectile2.sprite, projectile2.position, Color.White);
}
spriteBatch.End();
// TODO: Add your drawing code here
base.Draw(gameTime);
}