【发布时间】:2012-07-31 05:25:03
【问题描述】:
我是 XNA 的初学者,正在尝试我的新 kinect for windows,因此决定学习教程:http://digitalerr0r.wordpress.com/2011/06/20/kinect-fundamentals-2-basic-programming/
做完这个之后,我注意到所有的颜色都染成了浅蓝色。例如,RGB 20、20、20 的颜色看起来像深蓝色而不是深灰色。
我注意到GraphicsDevice.Clear() 正在使用Color.CornflowerBlue。我尝试将其更改为Color.Black,果然所有的东西现在都染成了黑色。
GraphicsDevice.Clear(color) 和绘制到屏幕上的颜色有什么关系?
这是我的绘图功能:
/// <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.Black);
spriteBatch.Begin();
spriteBatch.Draw(kinectRGBVideo, new Rectangle(0, 0, 640, 480), Color.White);
spriteBatch.DrawString(font, connectedStatus, new Vector2(20, 80), Color.Black);
spriteBatch.End();
base.Draw(gameTime);
}
【问题讨论】:
-
尝试在调用spriteBatch.Begin() 方法时更改BlendState。这决定了颜色在相互叠加时如何混合。
-
不错!它工作得很好,将其更改为答案,我会接受它。哦对了,你知道为什么使用 BlendState.Opaque 会导致文本显示为块吗?