2010-01-21 23 views
0

我目前有一個動畫,無限旋轉,但它只是開始太快...我試着降低到12的FPS,但它只是跳過....是否有可能通過這個代碼,以使動畫更慢:如何使他們所有山姆的速度(AS3)

//Import TweenMax 
import com.greensock.TweenMax; 

//Save the horizontal center 
var centerX:Number = stage.stageWidth/2; 

//Save the width of the whole gallery 
var galleryWidth:Number = infiniteGallery.width; 

//Speed of the movement (calculated by the mouse position in the moveGallery() function) 
var speed:Number = 0.02; 

//Add an ENTER_FRAME listener for the animation 
addEventListener(Event.ENTER_FRAME, moveGallery); 

function moveGallery(e:Event):void { 

    //Calculate the new speed 
    speed = -(0.02 * (mouseX - centerX)); 

    //Update the x coordinate 
    infiniteGallery.x+=speed; 

    //Check if we are too far on the right (no more stuff on the left edge) 
    if (infiniteGallery.x>0) { 

     //Update the gallery's coordinates 
     infiniteGallery.x= (-galleryWidth/2); 
    } 

    //Check if we are too far on the left (no more stuff on the right edge) 
    if (infiniteGallery.x<(-galleryWidth/2)) { 

     //Update the gallery's coordinates 
     infiniteGallery.x=0; 
    } 
} 

這裏是demo »

+1

比0.02更小的數字調節速度? var speed:Number = 0.01; speed = - (speed *(mouseX - centerX)); – maxmc 2010-01-21 14:33:35

+0

是的,但如果我這樣做,它立即移動停止動畫。 – 2010-01-21 14:48:25

回答

1

嘗試在speed = -(0.02 * (mouseX - centerX));

相關問題