0
嘿,當我的球員在跳躍的地方,我無法向左或向右移動,但當他着陸時我可以移動。我需要這在我的跳躍,使我不能移動的平臺上鍊接等..不能在左側或右側跳躍
這裏是我的代碼:
public void handleInput(GameTime gameTime)
{
this.Transform.MoveIncrement = Vector2.Zero;
float timeBetweenUpdates = 0.25f * gameTime.ElapsedGameTime.Milliseconds;
if (game.KeyboardManager.isKeyDown(left))
{
this.Transform.MoveIncrement += -this.Transform.Look * timeBetweenUpdates;
this.Transform.IsMoved = true;
}
if (game.KeyboardManager.isKeyDown(right))
{
this.Transform.MoveIncrement += this.Transform.Look * timeBetweenUpdates;
this.Transform.IsMoved = true;
}
if (game.KeyboardManager.isKeyDown(up) && hasJumped == false)
{
this.Transform.moveBy(-Vector2.UnitY * 400);
this.Transform.IsMoved = true;
hasJumped = true;
}
if (hasJumped == true)
{
this.Transform.MoveIncrement = Vector2.UnitY * timeBetweenUpdates;
this.Transform.IsMoved = true;
//hasJumped = false;
}
}
解決了我創建了一個方法moveBy並將moveIncrement更改爲此。我不知道我能覆蓋那個價值。非常感謝 :)。 –