您好,登錄后才能下訂單哦!
需求:
找到了黃馬褂的結(jié)構(gòu):
我們新建一個DragonBones項目 , 用以為上述黃馬褂換膚
我們對DragonE_view進行修改
///<reference path="./../tools/DragonBoneTools.ts" /> module app { export class DragonE_View extends eui.Component implements eui.UIComponent { private com_dragon : eui.Group; private img_dragon : eui.Image; private txt_name : eui.Label; private egretFactory : dragonBones.EgretFactory; private eff_robot : dragonBones.EgretArmatureDisplay; public constructor() { super(); this.skinName = "resource/eui_skins/DragonE.exml"; } protected partAdded(partName : string , instance : any):void{ super.partAdded(partName , instance); } protected childrenCreated():void{ super.childrenCreated(); this.txt_name.text = "Snow"; this.img_dragon.source = RES.getRes("egret_icon_png"); this.playDragonEff(); } /** *刷新機器人特效 */ public playDragonEff(): void { // this.loadChibangByResName("Robot_json"); this.loadChibangByResName("Dragon_ske_json"); } /** * 異步Robot動畫資源 */ private loadChibangByResName(name: string): void { var self = this; RES.getResAsync(name, function(data: any,key: string): void { if(key == "Dragon_ske_json") { self.loadChibangByResName("Dragon_tex_json"); } else if(key == "Dragon_tex_json") { self.loadChibangByResName("Dragon_tex_png"); } else if(key == "Dragon_tex_png") { this.showRoleWing(); } }, this); } /** * 展示Robot特效 */ private showRoleWing(wingId: number): void { this.egretFactory = tools.DragonBoneTools.Instance.createEff2New( "Dragon_ske_json", "Dragon_tex_json", "Dragon_tex_png", ); this.eff_robot = this.egretFactory.buildArmatureDisplay("Dragon"); this.addChild(this.eff_robot); this.eff_robot.animation.play("jump",0); this.eff_robot.x = 200; this.eff_robot.y = 450; this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouch,this); } private onTouch(evt: egret.TouchEvent) : void{ if(evt.type == egret.TouchEvent.TOUCH_BEGIN) { this.changeClothes(); } } private changeClothes():void{ this.loadChangeByResName("DragonChange_ske_json"); } private loadChangeByResName(name : string) : void{ var self = this; RES.getResAsync(name, function(data: any,key: string): void { if(key == "DragonChange_ske_json") { self.loadChangeByResName("DragonChange_tex_json"); } else if(key == "DragonChange_tex_json") { self.loadChangeByResName("DragonChange_tex_png"); } else if(key == "DragonChange_tex_png") { this.changeRoleWing(); } }, this); } private changeRoleWing():void{ this.egretFactory.parseDragonBonesData(RES.getRes("DragonChange_ske_json")); this.egretFactory.parseTextureAtlasData(RES.getRes("DragonChange_tex_json"), RES.getRes("DragonChange_tex_png")); this.egretFactory.replaceSlotDisplay( "DragonChange", "Armature", "clothes2", "clothes2", this.eff_robot.armature.getSlot("clothes")); } } }
重點 :
this.egretFactory.parseDragonBonesData(RES.getRes("DragonChange_ske_json"));
this.egretFactory.parseTextureAtlasData(RES.getRes("DragonChange_tex_json"), RES.getRes("DragonChange_tex_png"));
this.egretFactory.replaceSlotDisplay( "DragonChange", "Armature", "clothes2", "clothes2", this.eff_robot.armature.getSlot("clothes"));
replaceSlotDisplay : 替換一個骨頭的顯示
第一個參數(shù) : 替換項目的名稱
第二個參數(shù) : 替換目場景名字
第三個參數(shù) : 替換項目的骨骼名字
第五個參數(shù) : 替換項目的圖片名字
第五個參數(shù) : 被替換項目的卡槽
結(jié)果 :
全局換裝 ::://將圖集全部替換
ar.armature.replaceTexture(RES.getRes("new_db_texture_png"));
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。