[]animate 动画播放 怎么把攻击 开火 合起来播放
// 程序入口
class GameMain {
private roleAni: Laya.Animation;
private timeLine:Laya.TimeLine = new Laya.TimeLine();
constructor() {
//初始化舞台
Laya.init(1334, 750, Laya.WebGL);
//创建动画实例
this.roleAni = new Laya.Animation();
//加载动画图集,加载成功后执行回调方法
this.roleAni.loadAtlas("res/atlas/imgs/role/wp116.atlas", Laya.Handler.create(this, this.onLoaded));
}
private onLoaded(): void {
//添加到舞台
Laya.stage.addChild(this.roleAni);
//创建动画模板dizziness
Laya.Animation.createFrames(this.aniUrls("die", 4), "die");
Laya.Animation.createFrames(this.aniUrls("fire", 7), "fire");
Laya.Animation.createFrames(this.aniUrls("atk", 3), "atk");
Laya.Animation.createFrames(this.aniUrls("move", 4), "move");
Laya.timer.loop(1000, this, this.animateTimeBased);
}
private animateTimeBased() {
this.roleAni.interval = 100;
//循环播放动画
this.roleAni.play(0, false, "atk");
//this.roleAni.play(0,true,"fire");
//this.timeLine.addLabel("turnRight",0).to( this.roleAni.play(0, false, "atk"));
}
/**
* 创建一组动画的url数组(美术资源地址数组)
* aniName 动作的名称,用于生成url
* length 动画最后一帧的索引值,
*/
private aniUrls(aniName: string, length: number): any {
var urls: any = [];
for (var i: number = 1; i < length; i++) {
//动画资源路径要和动画图集打包前的资源命名对应起来
urls.push("imgs/role/wp116/" + aniName + i + ".png");
}
return urls;
}
}
new GameMain();
没有找到相关结果
已邀请:
1 个回复
Aar0n
赞同来自: