2010-01-21 4 views
0

J'ai actuellement une animation qui tourne à l'infini, mais c'est juste trop rapide pour commencer ... J'ai essayé d'abaisser le fps à 12, mais ce serait juste sauter .... est-il possible de faire l'animation plus lente par ce code:Comment les faire tous sam vitesse (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; 
    } 
} 

est ici le demo »

+1

régler la vitesse? var vitesse: nombre = 0,01; vitesse = - (vitesse * (mouseX - centerX)); – maxmc

+0

oui mais si je le fais ça bouge les arrêts l'animation tout de suite. –

Répondre

1

Essayez un nombre inférieur à 0,02 speed = -(0.02 * (mouseX - centerX));

Questions connexes