0
嗨請看看代碼。當我按下鍵盤對象下山我想要什麼卻是,當它達到一定的深度,它也應該back..any幫助將不勝感激,謝謝使影片剪輯自動回落到一定深度後回來
//rope coding
var rope = MovieClip(this.root).boat_mc.rope_mc;
var ropeMove:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME, ropeCode);
stage.addEventListener(KeyboardEvent.KEY_UP, onSpacebarUp);
function onSpacebarUp(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.SPACE)
ropeMove = !ropeMove; // toggles ropeMove (i.e. if it's true, sets it to false, and vice versa)
}
function ropeCode(e:Event):void
{
//check direction of rope
if(yDirection)
{
rope.y += ropeSpeed;
}
else
{
rope.y -= ropeSpeed;
}
// move the rope
if(ropeMove)
{
if(rope.y < 230)
{
yDirection = true;
trace(rope.y);
}
// stop moving if we've gone too far
else if (rope.y > 230)
{
yDirection = false;
}
}
}
不幸的是,它會開始回來,一旦它跳到深度,然後立即回落並進入循環 – Anando
現在movieclip只是開始自己下降,並繼續前進..不倒任何東西它甚至不等待空格鍵被點擊lol,請檢查上面的新代碼 – Anando
看到的問題是當我聲明布爾值它的真或假,並且因此..它自動啓動向上或向下。 – Anando