【发布时间】:2014-05-11 07:34:32
【问题描述】:
public function movementChar()
{
if (upKey)
{
this.y -= 10;
this.gotoAndStop("jump");
//this.scaleX = -1;
}
else
if (leftKey)
{
this.x -= xSpeed;
this.gotoAndStop("run");
this.scaleX = -1;
}
else if (rightKey)
{
this.x += xSpeed;
this.gotoAndStop("run");
this.scaleX = 1;
}
else if(!leftKey || !rightKey)
{
this.gotoAndStop("stop");
}
}
按住左键可以左移,按住右键可以右移, 但是当我按下时,角色会跳跃并且不会移动,但只有当我按住左键和上键||时才会向上移动右键和向上键。
如果有帮助,这里是其余的代码。
private function keyUp(e:KeyboardEvent):void
{
if (e.keyCode == 37)
{
leftKey = false;
}
if (e.keyCode == 39)
{
rightKey = false;
}
if (e.keyCode == 38)
{
upKey = false;
}
}
private function keyDown(e:KeyboardEvent):void
{
if (e.keyCode == 37)
{
leftKey = true;
}
if (e.keyCode == 39)
{
rightKey = true;
}
if (e.keyCode == 38)
{
upKey = true;
}
}
【问题讨论】:
标签: actionscript-3 game-engine