LoginSignup
1
0

More than 3 years have passed since last update.

TweenMaxで「0→任意の値→0」という値の変化をつくる

Posted at

TweenMaxで「0→任意の値→0」という値の変化をつくる

hoge.js
var obj = {
  propA: 0,
}

var forth = 10;
var tm = TweenMax.to(obj, 5, {
        onUpdate : function(){
            //進捗を0-1の値で返すtweenmaxのメソッド
            var progress = this.progress();
            //三角関数で0から180度のとき0→1→0を返すことを利用
            var num = Math.sin(progress * 180 * Math.PI / 180);
            //強度の値をかけることで、任意の時間に「0→任意の値→0」という値の変化をつくる
            var final = num * forth;
            final = Math.round(final * 100)/ 100;
            obj.propA = final;
            console.log(obj.propA);
        }
    });

もっと簡単な方法がある気がするす
toを続けて書く...?しかし任意のイージングのなかで変化させたい...ゆえにこのように記述しています

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0