1.新建一個TestIndex類,聲明愛心對象
1 private _love;//愛心對象
2.引入要展示的愛心對象
1 //引入愛心對象 2 this._love = CommonFun.creatBitmapByName("love_png"); 3 this.addChild(this._love);
3.設置愛心對象居中
1 //設置愛心居中顯示 2 this._love.anchorOffsetX = this._love.width / 2; 3 this._love.anchorOffsetY = this._love.height / 2; 4 this._love.x = Main.instance.width * .5; 5 this._love.y = Main.instance.height * .5;
4.利用Tween動畫設置愛心對象不停縮放
1 //設置愛心縮放顯示 2 egret.Tween.get(this._love,{loop:true}). 3 to({scaleX:0.5,scaleY:0.5},800,egret.Ease.sineIn). 4 to({scaleX:1,scaleY:1},800,egret.Ease.sineOut);

5.利用Tween動畫實現愛心旋轉
1 //設置愛心旋轉顯示 2 egret.Tween.get(this._love,{loop:true}). 3 to({rotation:360},2000,egret.Ease.sineIn);

6.利用動態幀頻實現愛心旋轉
1 this.addEventListener(egret.Event.ENTER_FRAME,()=>{ 2 // console.log('img.rotation = '+img.rotation); 3 img.rotation += 3; 4 },this);

