CocosCreator骨骼動(dòng)畫之龍骨DragonBones
CocosCreator版本2.3.4
龍骨動(dòng)畫
將龍骨動(dòng)畫放到cocos的assets下。我這里龍骨動(dòng)畫是Dragonbones導(dǎo)出的二進(jìn)制動(dòng)畫。

直接拖拽龍骨動(dòng)畫(骨頭圖標(biāo))到舞臺(tái)

設(shè)置骨骼動(dòng)畫的屬性,DragonAltasAsset圖片,Animation動(dòng)作,PlayTime循環(huán)播放等


代碼生成龍骨動(dòng)畫
龍骨資源路徑是assets/resources/dragonbones,loadResDir只需要填dragonbones就行了。
//根據(jù)路徑加載資源
cc.loader.loadResDir("dragonbones",cc.Asset,null,(err, resource)=>{
console.log("資源:",resource);
//生成骨骼動(dòng)畫
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);
//生成動(dòng)畫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);
//生成動(dòng)畫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);
//動(dòng)畫2的皮膚應(yīng)用到動(dòng)畫1上
let factory = dragonBones.CCFactory.getInstance();
factory.replaceSkin(armatureDisplay.armature(), (armatureDisplay2.armature() as dragonBones.Armature).armatureData.defaultSkin, true);
});
以上就是CocosCreator骨骼動(dòng)畫之龍骨DragonBones的詳細(xì)內(nèi)容,更多關(guān)于CocosCreator骨骼DragonBones的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- Unity使用物理引擎實(shí)現(xiàn)多旋翼無(wú)人機(jī)的模擬飛行
- Android下2d物理引擎Box2d用法簡(jiǎn)單實(shí)例
- 解讀CocosCreator源碼之引擎啟動(dòng)與主循環(huán)
- CocosCreator通用框架設(shè)計(jì)之資源管理
- 如何在CocosCreator中做一個(gè)List
- 剖析CocosCreator新資源管理系統(tǒng)
- 詳解CocosCreator制作射擊游戲
- 如何在CocosCreator里畫個(gè)炫酷的雷達(dá)圖
- 詳解CocosCreator MVC架構(gòu)
- 怎樣在CocosCreator中使用物理引擎關(guān)節(jié)
相關(guān)文章
微信小程序用戶授權(quán)環(huán)節(jié)實(shí)現(xiàn)過(guò)程
這篇文章主要介紹了微信小程序用戶授權(quán)環(huán)節(jié)實(shí)現(xiàn)過(guò)程,在商城項(xiàng)目中,我們需要對(duì)部分的頁(yè)面,進(jìn)行一個(gè)授權(quán)的判別,例如購(gòu)物車,及個(gè)人中心,需要完成用戶信息的授權(quán)后,獲取到相關(guān)信息2023-01-01
JavaScript實(shí)現(xiàn)經(jīng)緯度轉(zhuǎn)換常用方法總結(jié)
WGS84坐標(biāo)系、GCJ02坐標(biāo)系、BD09坐標(biāo)系和Web 墨卡托投影坐標(biāo)系是我們常見的四個(gè)坐標(biāo)系。這篇文章為大家整理了這四個(gè)坐標(biāo)系之間相互轉(zhuǎn)換的方法,需要的可以參考一下2023-02-02
pc加載更多功能和移動(dòng)端下拉刷新加載數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了pc加載更多功能和移動(dòng)端下拉刷新加載數(shù)據(jù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
JavaScript實(shí)現(xiàn)當(dāng)網(wǎng)頁(yè)加載完成后執(zhí)行指定函數(shù)的方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)當(dāng)網(wǎng)頁(yè)加載完成后執(zhí)行指定函數(shù)的方法,實(shí)例分析了javascript加載頁(yè)面及執(zhí)行函數(shù)的技巧,需要的朋友可以參考下2015-03-03
video.js 一個(gè)頁(yè)面同時(shí)播放多個(gè)視頻的實(shí)例代碼
這篇文章主要介紹了video.js 一個(gè)頁(yè)面同時(shí)播放多個(gè)視頻的實(shí)例代碼 ,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-11-11

