生easing
ライブラリを使わないで生でイージングを使うテスト。
sineEaseInOutメソッド
t 経過時間(フレーム)
b 初期値
c 変異値
d トータル時間(フレーム)
/**
* Copyright whirlpower ( http://wonderfl.net/user/whirlpower )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jS3U
*/
package
{
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite
{
private var ball : Ball;
private var count : int = 0;
public function FlashTest()
{
ball = new Ball();
ball.x = 100;
ball.y = 200;
addChild( ball );
addEventListener( Event.ENTER_FRAME, loop );
}
private function loop( e:Event ):void
{
ball.x = sineEaseInOut( count, 100, 300, 30 );
count++;
}
private function sineEaseInOut(t:Number, b:Number, c:Number, d:Number):Number
{
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
}
}
}
import flash.display.Sprite;
internal class Ball extends Sprite
{
public function Ball( color:uint = 0xFF0000, radius:Number = 10 ):void
{
graphics.beginFill( color );
graphics.drawCircle( 0, 0, radius );
graphics.endFill();
}
}