zoukankan      html  css  js  c++  java
  • 缓动

    1)何时停止缓动:

    private function onEnterFrame(event : Event) : void {

    var dx:Number = targetX - ball.x;

    if (Math.abs(dx) < 1){

    ball.x = targetX;

    removeEventListener(Event.ENTER_FRAME,onEnterFrame);

    } else {

    var vx:Number = dx * easing;

    ball.x += vx;

    }

    }

    }

    2) 重影效果可以让第一个影子缓动至物体,第二个影子缓动至第一个影子,第三个影子缓动至第二个影子。。。

    function onEnterFrame(event:Event): void{

    moveBall(ball0,mouseX,mouseY);

    moveBall(ball1,ball0.x,ball0.y);

    moveBall(ball2,ball1.x,ball1.y);

    }

    private function moveBall(ball:Ball,targetX:Number,targetY:Number):void{

    ball.vx += (targetX - ball.x) * spring;

    ball.vy += (targetY - ball.y) * spring;

    ball.vy += gravity;

    ball.vx *= friction;

    ball.vy *= friction;

    ball.x += ball.vx;

    ball.y += ball.vy;

    }

    3) 缓动:

    ball.x += (targetX - ball.x) * 0.2;

    ball.y += (targetY - ball.y) * 0.2;

    4) 弹性:

    dx = targetX - ball.x;

    dy = targetY - ball.y;

    ax = dx * 0.2;

    ay = dx * 0.2;

    vx += ax;

    vy += ay;

    vx *= friction;

    vy *= friction;

    ball.x += vx;

    ball.y += vy;

  • 相关阅读:
    学习进度总结表
    关于软件工程的问题
    自我介绍
    web安全
    spring profile
    spring 装配
    python Descriptor (描述符)
    python string intern
    Java 对象内存占用
    java jdb命令详解
  • 原文地址:https://www.cnblogs.com/cly84920/p/4426645.html
Copyright © 2011-2022 走看看