laya龙骨换装_刘先生-laya龙骨动画的几种使用方法

第一种直接加载显示:var skeleton:Laya.Skeleton = new Laya.Skeleton();

//添加到舞台

this.addChild(skeleton);

skeleton.pos(300,350);

//通过加载直接创建动画

skeleton.load("res/skeletonEffect/win/xiaobingWIN.sk", new Laya.Handler(this, function(){

// console.log("!!!!!!!!!!!!!!!!!!!~~~~",skeleton.getAnimNum());

skeleton.play(1,false);

},null,true));

skeleton.on(LayaEvent.STOPPED, this, function(){console.log("STOPPED!!!!")})

skeleton.on(LayaEvent.PAUSED, this, function(){console.log("PAUSED!!!!")})

skeleton.on(LayaEvent.LABEL, this, function(){console.log("LABEL!!!!")})

skeleton.on(LayaEvent.PLAYED, this, function(){console.log("PLAYED!!!!")})

第二种预加载:var mFactory = new Laya.Templet();

mFactory.on(LayaEvent.COMPLETE, this, function(){

var mArmature = mFactory.buildArmature(0);

mArmature.x = 300;

mArmature.y = 300;

this.addChild(mArmature);

mArmature.play(1, true);

});

mFactory.loadAni("res/skeletonEffect/win/xiaobingWIN.sk");

第三种很多的时候一起打包预加载:this.mTexturePath = "../../res/skeleton/" + this.fileName + "/" + this.fileName + ".png";

this.mAniPath = "../../res/skeleton/" + this.fileName + "/" + this.fileName + ".sk";

Laya.loader.load([{ url: this.mTexturePath, type: Loader.IMAGE }, { url: this.mAniPath, type: Loader.BUFFER }], Handler.create(this, this.onAssetsLoaded));

public onAssetsLoaded(): void {

var tTexture: Texture = Loader.getRes(this.mTexturePath);

var arraybuffer: ArrayBuffer = Loader.getRes(this.mAniPath);

this.mFactory = new Templet();

this.mFactory.on(Event.COMPLETE, this, this.parseComplete);

this.mFactory.parseData(tTexture, arraybuffer, 10);

}

this.mArmature = this.mFactory.buildArmature();

this.mArmature.x = this.xOff + j * this.mSpacingX;

this.mArmature.y = this.yOff + i * this.mSpacingY;

this.mArmature.play(0, true);

this.mAnimationArray.push(this.mArmature);

Laya.stage.addChild(this.mArmature);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值