游戏中会用着一些简单的动画,公司一般使用的dragonbones制作,导出二进制格式或者MC来使用。
感觉一些简单动画直接使用动画编辑器更加简便些。



引擎版本:5.0.14
wing版本:4.1.0

一 效果图

【咸鱼教程】Wing动画编辑器创建精美(一般-_-)开场动画 

OpenAnim.ts

[AppleScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * 开场动画
 * @author chenkai 2018/2/25
 */
class OpenAnim extends eui.Component{
        private openAnim:egret.tween.TweenGroup;   //开场动画
 
        public constructor() {
                super();
                this.skinName = "OpenAnimSkin";
                this.percentWidth = 100;
                this.percentHeight = 100;
        }
 
        public childrenCreated(){
 
        }
 
        //播放
        public play(){
                this.openAnim.addEventListener(egret.Event.COMPLETE, this.onTweenGroupComplete, this);
        this.openAnim.play();
        }
 
        //停止
        public stop(){
                this.openAnim.stop();
        }
  
    //动画播放完成
    private onTweenGroupComplete(): void {
                this.openAnim.removeEventListener(egret.Event.COMPLETE, this.onTweenGroupComplete, this);
                this.dispatchEvent(new egret.Event(egret.Event.COMPLETE));
    }
 
}



我们在其他exml中使用这个动画,可以使用代码创建,或者直接拖动到其他exml中

这里拖动一个openAnim动画到主页HomeSceneSkin皮肤上,并在代码中使用
【咸鱼教程】Wing动画编辑器创建精美(一般-_-)开场动画 

[AppleScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * 主页
 * @author chenkai 2018/2/25
 */
class HomeScene extends eui.Component{
        private openAnim:OpenAnim;   //开场动画
 
        public constructor() {
                super();
                this.percentWidth = 100;
                this.percentHeight = 100;
                this.skinName = "HomeSceneSkin";
        }
 
        protected childrenCreated(){
                super.childrenCreated();
 
                this.openAnim.addEventListener(egret.Event.COMPLETE, this.onAnimComplete, this);
                this.openAnim.play();
        }
 
        private onAnimComplete(){
                console.log("动画播放完成");
        }
}




三 Demo下载

https://files-cdn.cnblogs.com/files/gamedaybyday/Egret5.0.13_AnimDemo.7z

 

相关文章:

  • 2021-11-08
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
猜你喜欢
  • 2022-01-14
  • 2021-11-11
  • 2021-08-10
  • 2021-09-30
  • 2021-09-17
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案