如何在GameQuery中停止动画

时间:2011-08-25 11:48:38

标签: javascript jquery gamequery

我有一个使用GameQuery启动的图像动画。现在我想停止动画。为此,我使用了以下代码。

imgAnimation["myimage"] = new $.gameQuery.Animation({imageURL: imgPath + "test.png",  numberOfFrame: 3, delta: 130, rate: 236,
       type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK});

       $("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH})
       .addGroup("actors", {width: PLAYGROUND_WIDTH, height: PLAYGROUND_HEIGHT})
       .addSprite("myimage",{animation: imgAnimation["myimage"],
       posx: imgXPos, posy: 0, width: 128, height: 384, callback: callbackAnimation})

       function callbackAnimation(){
         $("#myimage").stop();
         $("#myimage").clearQueue(); 
       }

       $.playground().startGame();

但这似乎不起作用。但与此同时,如果我在同一个动画元素(hide())上使用$("#myimage")方法,它就可以工作。

这两种方法都只是jQuery API的一部分。

但为什么停止方法不起作用?

提前致谢。

1 个答案:

答案 0 :(得分:2)

对于gameQuery的0.5.x版本来说这是不可能的,但是0.6刚出来并添加pauseAnimation()resumeAnumation(),这应该就是你想要的。