在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
CocosCreator版本2.3.4 龙骨动画将龙骨动画放到cocos的assets下。我这里龙骨动画是Dragonbones导出的二进制动画。 直接拖拽龙骨动画(骨头图标)到舞台 设置骨骼动画的属性,DragonAltasAsset图片,Animation动作,PlayTime循环播放等 代码生成龙骨动画龙骨资源路径是assets/resources/dragonbones,loadResDir只需要填dragonbones就行了。 //根据路径加载资源 cc.loader.loadResDir("dragonbones",cc.Asset,null,(err, resource)=>{ console.log("资源:",resource); //生成骨骼动画 let node:cc.Node = new cc.Node(); let armatureDisplay:dragonBones.ArmatureDisplay = node.addComponent(dragonBones.ArmatureDisplay); armatureDisplay.dragonAsset = resource[0]; armatureDisplay.dragonAtlasAsset = resource[3]; armatureDisplay.armatureName = "role3"; armatureDisplay.playAnimation("move",0); node.x = 100; node.y = 100; this.node.addChild(node); }); 替换皮肤//加载资源 cc.loader.loadResDir("dragonbones",cc.Asset,null,(err, resource)=>{ console.log("资源:",resource); //生成动画1 let node:cc.Node = new cc.Node(); let armatureDisplay:dragonBones.ArmatureDisplay = node.addComponent(dragonBones.ArmatureDisplay); armatureDisplay.dragonAsset = resource[0]; armatureDisplay.dragonAtlasAsset = resource[3]; armatureDisplay.armatureName = "role3"; armatureDisplay.playAnimation("move",0); node.x = 100; node.y = 100; this.node.addChild(node); //生成动画2 let node2:cc.Node = new cc.Node(); let armatureDisplay2:dragonBones.ArmatureDisplay = node2.addComponent(dragonBones.ArmatureDisplay); armatureDisplay2.dragonAsset = resource[4]; armatureDisplay2.dragonAtlasAsset = resource[7]; armatureDisplay2.armatureName = "role4"; armatureDisplay2.playAnimation("move",0); node2.x = 150; node2.y = 150; this.node.addChild(node2); //动画2的皮肤应用到动画1上 let factory = dragonBones.CCFactory.getInstance(); factory.replaceSkin(armatureDisplay.armature(), (armatureDisplay2.armature() as dragonBones.Armature).armatureData.defaultSkin, true); }); 以上就是CocosCreator骨骼动画之龙骨DragonBones的详细内容,更多关于CocosCreator骨骼DragonBones的资料请关注极客世界其它相关文章! |
请发表评论