我正在为monogame编写一个GameObject类(精灵的位置,alpha,旋转等等)
当我开始缩放图像时,我遇到了问题。有没有办法在不损失质量的情况下缩放图像?
以下是我渲染所有内容的方式
foreach (KeyValuePair<int, GameObject> go in RenderObjects)
{
spriteBatch.Draw(go.Value.img, go.Value.getRect(), go.Value.RenderArea, Color.White * (float)go.Value.alpha, (float)go.Value.rotation, go.Value.getCenter(), SpriteEffects.None, 0f);
}
如果您尝试将16x64图像缩放到160x640
,则会发生以下情况^^^^^^^^^^^^^^^^^^
答案 0 :(得分:1)
我一直在搞乱monogame,我意外地找到了解决方案。 您只需要向spriteBatch.Begin();
添加一些参数spriteBatch.Begin(... , ... ,SamplerState.PointClamp);
foreach (KeyValuePair<int, GameObject> go in RenderObjects)
{
spriteBatch.Draw(go.Value.img, go.Value.getRect(), go.Value.RenderArea, Color.White * (float)go.Value.alpha, (float)go.Value.rotation, go.Value.getCenter(), SpriteEffects.None, 0f);
}
spriteBatch.End();
实际上有更多方法可以做到,但我不太明白如何做到这一点。与graphics.GraphicsDevice有关的东西