在 XNA 中调整大小并加载texture2d
我是 XNA 的新手,以防万一。我尝试做的是加载与原始大小不同的纹理,或者至少有可能在之后更改他的大小。我在一些地方看到我可以使用:
Texture2D.FromStream(GraphicsDevice graphicsDevice, Stream stream,
int width, int height, bool zoom)
但我也读到以这种方式加载纹理会忽略 ContentManager,并且我使垃圾收集器的工作变得更加困难。
使用 ContentManager 加载任何尺寸的图像的正确方法是什么? 如果这不可能,我可以按比例改变他的大小,比如使用变焦吗?
语境: 我正在创建一个 nxn 和平委员会。当 n 太大时,我需要自动变得更小。
i'm a newbie in XNA just in case. What i try to do is load a texture in a different size from his original, or at least have the possibility to change his size after. I see in some places that i can use:
Texture2D.FromStream(GraphicsDevice graphicsDevice, Stream stream,
int width, int height, bool zoom)
But i also read that loading textures in this way is ignoring the ContentManager, and that i'm making the job for the garbage collector more difficult.
What is the Correct way to load an image in any size, using the ContentManager ?
If that isn't possible can i change his size proportionally, like using a zoom?
Context:
I'm creating a board of n x n peaces. When n is too big i need that automatically the peaces becomes more smaller.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
加载纹理:
要调整其大小,请使用采用“scale”的 SpriteBatch 重载之一
http://msdn.microsoft.com /en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspx
如果您是 XNA 新手,我建议您阅读 这个简短教程,并查看 教育目录,位于 create.msdn.com
To load the texture:
To resize it use one of the SpriteBatch overloads that takes "scale"
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspx
If you are new to XNA, I suggest you read this short tutorial, and also check out Education Catalog at create.msdn.com