您好我必须旋转一个Texture2D,但我不知道为什么。 它像一个有图片,我需要旋转180°,因为它在头上,应该是正确的。如何在XNA游戏工作室中旋转Texture2D?
问题是,我需要这样做之前我使用spriteBatch.Draw
,这可能吗?
您好我必须旋转一个Texture2D,但我不知道为什么。 它像一个有图片,我需要旋转180°,因为它在头上,应该是正确的。如何在XNA游戏工作室中旋转Texture2D?
问题是,我需要这样做之前我使用spriteBatch.Draw
,这可能吗?
纹理将被旋转180度。
protected override void Draw(GameTime gameTime)
{
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null);
spriteBatch.Draw(texture, Position, null, Color.White, (float)Math.PI, new Vector2(texture.Width, texture.Height), 1, SpriteEffects.None, 0);
spriteBatch.End();
base.Draw(gameTime);
}
正如你也可以使用SpriteEffects垂直翻转质地:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null);
spriteBatch.Draw(texture, Position, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.FlipVertically, 0);
spriteBatch.End();
base.Draw(gameTime);
}
这翻转是我需要的! – gurehbgui 2012-04-13 06:22:54