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

直接拖拽龍骨動畫(骨頭圖標(biāo))到舞臺

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


代碼生成龍骨動畫
龍骨資源路徑是assets/resources/dragonbones,loadResDir只需要填dragonbones就行了。
//根據(jù)路徑加載資源
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的皮膚應(yīng)用到動畫1上
let factory = dragonBones.CCFactory.getInstance();
factory.replaceSkin(armatureDisplay.armature(), (armatureDisplay2.armature() as dragonBones.Armature).armatureData.defaultSkin, true);
});
以上就是CocosCreator骨骼動畫之龍骨DragonBones的詳細(xì)內(nèi)容,更多關(guān)于CocosCreator骨骼DragonBones的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
微信小程序用戶授權(quán)環(huán)節(jié)實(shí)現(xiàn)過程
這篇文章主要介紹了微信小程序用戶授權(quán)環(huán)節(jié)實(shí)現(xiàn)過程,在商城項(xiàng)目中,我們需要對部分的頁面,進(jìn)行一個授權(quán)的判別,例如購物車,及個人中心,需要完成用戶信息的授權(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)系是我們常見的四個坐標(biāo)系。這篇文章為大家整理了這四個坐標(biāo)系之間相互轉(zhuǎn)換的方法,需要的可以參考一下2023-02-02
JavaScript實(shí)現(xiàn)當(dāng)網(wǎng)頁加載完成后執(zhí)行指定函數(shù)的方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)當(dāng)網(wǎng)頁加載完成后執(zhí)行指定函數(shù)的方法,實(shí)例分析了javascript加載頁面及執(zhí)行函數(shù)的技巧,需要的朋友可以參考下2015-03-03
video.js 一個頁面同時播放多個視頻的實(shí)例代碼
這篇文章主要介紹了video.js 一個頁面同時播放多個視頻的實(shí)例代碼 ,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2018-11-11

