egret 示例实战二:实现爱心缩放和旋转动画 您所在的位置:网站首页 旋转爱心动态图片 egret 示例实战二:实现爱心缩放和旋转动画

egret 示例实战二:实现爱心缩放和旋转动画

2024-06-18 06:30| 来源: 网络整理| 查看: 265

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);

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有