XNA - 如何使屏幕的一部分变暗? [英] XNA - How to dim a section of the screen?
问题描述
如何使图像(或屏幕的一部分)变暗,以便可以显示其他未变暗的内容作为焦点?抱歉,这有点模糊且难以理解,但我想不出更好的表达方式.
How would you dim an image(or a section of the screen) so that you can show something else that's not dimmed as the focus? Sorry that it's a little vague and hard to understand, but I can't think of a better way to phrase it.
推荐答案
我不知道这有多高效或多智能,但 spriteBatch.Draw 需要一种颜色来为纹理着色.您可以尝试设置一个纹理列表,并为要变暗的纹理应用较深的颜色.
I don't know how efficient or smart this is, but spriteBatch.Draw takes a color to shade textures. You could try setting up a list of textures and apply darker colors to the textures that are meant to be dimmed.
类似于:
for(int i = 0; i < texturesToDraw.Count; i++)
{
if(i == selected)
{
spriteBatch.Draw(texturesToDraw[i], position, Color.White)
}
else
{
spriteBatch.Draw(texturesToDraw[i], position, Color.SomeDarkColor)
}
}
一个可以帮助您入门的简单教程:http://www.xnadevelopment.com/tutorials/fadeinfadeout/FadeInFadeOut.shtml
A simple tutorial that might help you get started: http://www.xnadevelopment.com/tutorials/fadeinfadeout/FadeInFadeOut.shtml
这篇关于XNA - 如何使屏幕的一部分变暗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!