XNA有关绘画方法的初学者问题 [英] XNA beginner question about draw method
问题描述
我知道我必须在draw()中绘制所有内容,并且它不断循环。
I understand that I have to draw everything in draw(), and it's looping continuously.
但是我不想一次又一次地绘制纹理,例如,我想创建一个纹理,绘制一些要纹理的东西(而不是spritebatch)。比我只会在draw()中绘制该纹理。
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?
推荐答案
不重新绘制它是一种性能优化。仅在确实需要时才应该这样做。
Not drawing it again is a performance optimisation. You should only do that if you really need to.
如果确实需要这样做,则创建一个渲染目标,将场景绘制为渲染目标,然后将渲染目标每帧绘制到屏幕上(使用 SpriteBatch
可以很容易地)而不是场景。
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.
这篇关于XNA有关绘画方法的初学者问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!