XNA - How to dim a section of the screen?

£可爱£侵袭症+ 提交于 2020-01-25 05:01:35

问题


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.


回答1:


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.

Something like:

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)
    }
}

A simple tutorial that might help you get started: http://www.xnadevelopment.com/tutorials/fadeinfadeout/FadeInFadeOut.shtml



来源:https://stackoverflow.com/questions/16600198/xna-how-to-dim-a-section-of-the-screen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!