XNA beginner question about draw method

半城伤御伤魂 提交于 2020-02-06 15:56:42

问题


I understand that I have to draw everything in draw(), and it's looping continuously.

But I don't want to draw texture again and again, for example I want to create a texture, draw something to texture (not spritebatch). than I will only draw that texture in draw().

Is it possible? What can I use?


回答1:


Not drawing it again is a performance optimisation. You should only do that if you really need to.

If you do need to do this, create a render target, draw your scene to the render target, and then draw your render target to the screen each frame (using SpriteBatch makes this easy) instead of your scene.

Take a look at this question about caching drawing using render targets.




回答2:


You have to draw again and again, as in short, if you dont it wont show. A wise man once wrote in a windows development book

Ask not why the text on your windows has to be constantly drawn, ask why it never used to be in DOS/Unix command line.

If something is placed over the area you're drawing too, and you dont redraw it, it just simply wont be there. You need to keep drawing it for it to be sustained on screen. Its done very quickly and wont hurt anything (especially if you're thinking in terms of background)



来源:https://stackoverflow.com/questions/5532620/xna-beginner-question-about-draw-method

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