こんにちは、Texture2D を回転させる必要がありますが、その理由がわかりません。写真を持っているようなもので、頭の上にあり、正しいはずなので、180°回転させる必要があります。
問題は、使用する前にそれを行う必要が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);
}
このDraw
メソッドには、テクスチャを回転させるためのオーバーロードがあります。描画する前にテクスチャを回転させる必要がある理由がわかりません。スケーリングと回転は通常、描画中に行われます。Joel が指摘しているように、回転はラジアンを使用して行われ、回転の中心である原点にも注意する必要があります。