0

好的,所以我正在用 Adob​​e Flash (air) 开发一个游戏,这将是一个手机游戏。我前一段时间问过这个问题,但是动画不起作用所以知道我回来了。无论如何,我遇到的问题是当我按住一个按钮时没有连续移动,所以我必须不断按下按钮才能移动。那个人告诉我使用滴答声,所以这就是我构建运动引擎的方式,围绕着滴答声.当我去添加我的动画时,它会运行一次然后停止(动画)这是我的代码:

myButton.addEventListener(MouseEvent.MOUSE_DOWN,mouseDown);

function mouseDown(e:Event):void {
    stage.addEventListener(MouseEvent.MOUSE_UP,mouseUp); //listen for mouse up on the stage, in case the finger/mouse moved off of the button accidentally when they release.
    addEventListener(Event.ENTER_FRAME,tick); //while the mouse is down, run the tick function once every frame as per the project frame, this is where I add the players animation.
}

function mouseUp(e:Event):void {
    removeEventListener(Event.ENTER_FRAME,tick);  //stop running the tick function every frame now that the mouse is up
    stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUp); //remove the listener for mouse up
}

function tick(e:Event):void {
    //do your movement
}

我的意思是,有没有办法解决这个问题?我怎样才能用勾号制作动画!

4

1 回答 1

0

和其他人一样,我发现代码非常好。因为,我无法访问整个代码和时间线,所以我对这个问题有以下猜测:

因为,您只想在鼠标按下时开始动画,所以您必须在动画的第一帧中有一个 stop() 动作。(如果不是这种情况,请纠正我)。动画的最后一帧必须再次执行 gotoAndPlay(x) 操作才能循环播放。

基于上述假设,当您的动画循环播放时,它会再次到达已经定义了 stop() 动作的帧。

于 2013-02-22T06:53:20.507 回答