所以我试图制作一个只是为了好玩的小游戏,但我很快就进入了一堵墙。我想要“播放器”(灰色框),从屏幕的正中心开始。然而,根据我目前的代码,它以盒子cornor而不是它的中心为中心。在它从盒子中心出发之前我还需要改变什么?
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport viewport = GraphicsDevice.Viewport;
Vector2 viewportmid = new Vector2(viewport.Width / 2, viewport.Height / 2);
Vector2 origin = new Vector2(Player.Width / 2, Player.Height / 2);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
spriteBatch.Draw(Player, viewportmid, Color.White, origin);
spriteBatch.End();
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}
提前致谢! =)网站新手,因此无法直接发布图片。下面是一个链接:http://imgur.com/43NiWNY