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();
}
}