1
私はXNAでシンプルな2人の船のシューティングゲームを作っています。スプライトは無作為に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);
}