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,并与显示宽度和高度相乘。屏幕位置是通过拖动屏幕获得的。对于其他元素,基元,位置是正确的,并且与输入一起正在被拖动。然而,当绘制一个精灵时,精灵正在快速移动,比输入快,给出了一种视差效果,而不是我想要的。精灵的位置
不知何故,我得到我使用的参数错误的感觉,spriteBatch.Draw(..)不需要pixelcoordinates ..
宽度和高度由质地装载机获得。
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。 –