0
我需要一些帮助。我试图让我的角色在静止的时候走向两个方向(左侧和右侧)和一个空闲的动画。我设法让角色走向右边,并让闲置的动画起作用。现在如果我将代码从右按钮复制到左按钮,则步行动画会卡在两个方向的第一帧中。我试图用它做实验,但没有运气。我很抱歉,如果我听起来小白。我刚开始学习编程。动作脚本3步行动画
这里是我使用的
RightBtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
function mouseDown(e:MouseEvent): void {
if(RightBtn){
isRight = true;
}
}
RightBtn.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
function mouseUp(e:MouseEvent): void {
if(RightBtn){
isRight = false;
}
}
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(Event){
if(isRight==true && mcPlayer.x < 750){
mcPlayer.x += 7;
mcPlayer.gotoAndStop (2);
mcPlayer.walkR.play();
}
else{
mcPlayer.gotoAndStop (1)
mcPlayer.Idle.play();
}
}
LeftBtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown2);
function mouseDown2(e:MouseEvent): void {
if(LeftBtn){
isLeft = true;
}
}
LeftBtn.addEventListener(MouseEvent.MOUSE_UP, mouseUp2);
function mouseUp2(e:MouseEvent): void {
if(LeftBtn){
isLeft = false;
}
}
stage.addEventListener(Event.ENTER_FRAME, loop2);
function loop2(Event){
if(isLeft==true && mcPlayer.x > 65){
mcPlayer.x -= 7;
mcPlayer.gotoAndStop (3);
mcPlayer.walkL.play();
}
else{
mcPlayer.gotoAndStop (1)
mcPlayer.Idle.play();
}
}