我正在用XNA游戏工作室4.0开发2D游戏,我需要让我的“英雄”精灵拍摄一个长方形的镜头精灵。用XNA游戏工作室在2D游戏按键拍摄
当我按下左控制器进行拍摄时,镜头从我的播放器开始。到目前为止,没关系,但问题是它永远不会停止 - 它的位置永远不会去theVoid
。
这是我拍摄代码:
protected override void Update(GameTime gameTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.LeftControl) && isShotted == false)
{
isShotted = true;
shotPosition = playerPosition;
}
if (isShotted == true && (shotPosition.X <= shotPosition.X+150))
{
shotPosition.X += shotSpeed.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
else
{
isShotted = false;
shotPosition = theVoid;
}
}
一些澄清:
playerPosition
是我的 “英雄” 精灵位置。theVoid
是Vector2 (700,700)
,当时我设置shotPosition = theVoid
这个镜头消失了。
'shotPosition.X <= shotPosition.X + 150'总是会是真的。 ..我想你可能意味着'playerPosition + 150'? – jonhopkins