【发布时间】:2013-01-21 22:33:46
【问题描述】:
Vector2 drawPos = (-screenPosition);
drawPos.X *= (float)device.DisplayMode.Width;
drawPos.Y *= (float)device.DisplayMode.Height;
spriteBatch.Draw(
texture,
drawPos,
getRectangle(),
Color.White,
rotation,
getOrigin(),
1.0f / zoom,
SpriteEffects.None,
0);
我有一个 drawPos 本质上是 0..1 并将其与显示宽度和高度相乘。 screenposition 是通过拖动屏幕获得的。对于其他元素,图元,位置是正确的,并且与输入一起被拖动。然而,当绘制一个精灵时,精灵移动得很快,比输入更快,产生了一种视差效果,这不是我想要的。
我感觉我使用的参数有误,并且 spriteBatch.Draw(..) 不需要像素坐标..
宽度和高度由纹理加载器获取。
public Vector2 getOrigin()
{
return new Vector2(width / 2, height / 2);
}
public Rectangle getRectangle()
{
return new Rectangle(
0,
0,
width,
height);
}
另外,我正在为 Windows Phone 开发。
【问题讨论】:
-
需要更多信息,您是指正在拖动的游戏窗口吗? screenPosition 是如何定义的?使用高度/宽度的视口属性:graphicsDevice.Viewport.Width/Height。