2015-07-21 76 views
1

我被告知,补间对象中的.to()方法将图形对象移动到画布上的精确点。但是,当我运行下面的代码时,.to()方法将400个像素添加到圆的原始x位置,即165.因此,该圆将转到565,但我希望它在画布上达到400像素。任何人都知道为什么会发生这种情况,我可以做些什么来让它在画布上达到400像素?TweenJS绝对位置(到()方法)不工作

<html> 
    <title>Pool Game</title> 
    <head> 
    <script src="https://code.createjs.com/easeljs-0.8.0.min.js"></script> 
    <script src="https://code.createjs.com/tweenjs-0.6.1.min.js"></script> 

    <script> 

    function init(){ 
     stage = new createjs.Stage("myCanvas"); 
     var circle = new createjs.Shape(); 
     circle.graphics.beginFill("blue"); 
     circle.graphics.drawCircle(165, 250, 25); 
     stage.addChild(circle); 
     stage.update(); 
     createjs.Tween.get(circle, {loop: false}) 
       .to({ x: 400}, 1000); 
     createjs.Ticker.setFPS(60); 
     createjs.Ticker.addEventListener("tick", stage); 
    } 

    </script> 

    </head> 
    <body onload="init();"> 
     <canvas id="myCanvas" width="1000" height="500"></canvas> 
    </body> 

</html> 

回答