如何使他们所有的山姆速度(AS3)

时间:2010-01-21 14:16:41

标签: flash actionscript-3 animation tween

我目前有一个无限旋转的动画,但它开始时速度太快......我尝试将fps降低到12但它只是跳过....有可能让动画变得更慢代码:

//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 :(得分:1)

speed = -(0.02 * (mouseX - centerX));

中尝试使用小于0.02的数字