mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-01-15 15:31:08 +00:00
1 line
5.0 KiB
Plaintext
1 line
5.0 KiB
Plaintext
{"version":3,"sources":["assets/spine/skin/spine-skin.ts"],"names":["_a","cc","_decorator","ccclass","property","SpineSkin","_super","__extends","_this","apply","this","arguments","addBoyBtn","removeBoyBtn","randomChangeBtn","boy","heads","boys","datas","prototype","start","boySpine","getComponentInChildren","sp","Skeleton","newSkeletonData","skeletonData","clone","animation","push","on","newBoy","instantiate","newBoySpine","parent","addChild","setPosition","length","position","x","setAnimationCacheMode","AnimationCacheMode","PRIVATE_CACHE","Label","string","destroy","setRegionData","RegionData","Math","floor","random","onDestroy","_b","__values","_c","next","done","data","value","__decorate","Node","SpriteFrame","Component","exports","default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAM,IAAAA,KAAAC,GAAAC,YAAAC,UAAAH,GAAAG,SAAAC,WAAAJ,GAAAI;IAGN,IAAAC,YAAA,SAAAC;MAAuCC,UAAAF,WAAAC;MAAvC,SAAAD;QAAA,IAAAG,QAAA,SAAAF,UAAAA,OAAAG,MAAAC,MAAAC,cAAAD;QAGIF,MAAAI,YAAA;QAGAJ,MAAAK,eAAA;QAGAL,MAAAM,kBAAA;QAGAN,MAAAO,MAAA;QAGAP,MAAAQ,QAAA;QAEAR,MAAAS,OAAA;QAEAT,MAAAU,QAAA;;;MAEUb,UAAAc,UAAAC,QAAA;QAAV,IAAAZ,QAAAE;QACI,IAAAW,WAAAX,KAAAK,IAAAO,uBAAAC,GAAAC;QACA,IAAAC,kBAAAJ,SAAAK,aAAAC;QACAN,SAAAK,eAAAD;QACAJ,SAAAO,YAAA;QAEAlB,KAAAQ,MAAAW,KAAAJ;QACAf,KAAAO,KAAAY,KAAAnB,KAAAK;QAEAL,KAAAE,UAAAkB,GAAA,SAAA;UACI,IAAAC,SAAA9B,GAAA+B,YA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GAAA2D,SAC4BvD,UAAAc,WAAA,qBAAA;MAG7BwC,WAAA,EADCvD,SAAAH,GAAA2D,SAC+BvD,UAAAc,WAAA,wBAAA;MAGhCwC,WAAA,EADCvD,SAAAH,GAAA2D,SACmBvD,UAAAc,WAAA,YAAA;MAGpBwC,WAAA,EADCvD,SAAA,EAAAH,GAAA4D,kBAC4BxD,UAAAc,WAAA,cAAA;MAfZd,YAAAsD,WAAA,EADpBxD,WACoBE;MAoErB,OAAAA;KApEA,CAAAJ,GAAA6D;IAAqBC,QAAAC,UAAA3D","sourcesContent":["const { ccclass, property } = cc._decorator;\n\n@ccclass\nexport default class SpineSkin extends cc.Component {\n\n @property(cc.Node)\n addBoyBtn: cc.Node = null;\n\n @property(cc.Node)\n removeBoyBtn: cc.Node = null;\n\n @property(cc.Node)\n randomChangeBtn: cc.Node = null;\n\n @property(cc.Node)\n boy: cc.Node = null;\n\n @property([cc.SpriteFrame])\n heads: cc.SpriteFrame[] = [];\n\n boys: cc.Node[] = [];\n\n datas: sp.SkeletonData[] = [];\n\n protected start(): void {\n const boySpine = this.boy.getComponentInChildren(sp.Skeleton);\n const newSkeletonData = boySpine.skeletonData.clone();\n boySpine.skeletonData = newSkeletonData;\n boySpine.animation = 'attack';\n\n this.datas.push(newSkeletonData);\n this.boys.push(this.boy);\n\n this.addBoyBtn.on('click', () => {\n const newBoy = cc.instantiate(this.boy);\n const newBoySpine = newBoy.getComponentInChildren(sp.Skeleton);\n newBoySpine.skeletonData = boySpine.skeletonData.clone();\n newBoySpine.animation = 'attack';\n\n this.boy.parent.addChild(newBoy);\n newBoy.setPosition(this.boys[this.boys.length - 1].position);\n newBoy.x += 100;\n if (this.boys.length % 2 === 1) {\n newBoy.getComponentInChildren(sp.Skeleton).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.PRIVATE_CACHE);\n newBoy.getComponentInChildren(cc.Label).string = `Spine - Cache`;\n }\n this.datas.push(newBoySpine.skeletonData);\n this.boys.push(newBoy);\n });\n\n this.removeBoyBtn.on('click', () => {\n if (this.boys.length > 1) {\n this.datas[this.datas.length - 1].destroy();\n this.boys[this.boys.length - 1].destroy();\n this.datas.length -= 1;\n this.boys.length -= 1;\n }\n });\n\n this.randomChangeBtn.on('click', () => {\n const boy = this.boys[this.boys.length - 1].getComponentInChildren(sp.Skeleton);\n boy.setRegionData('Head', 'Head', new sp.RegionData(this.heads[Math.floor(Math.random() * (this.heads.length))]));\n });\n }\n\n protected onDestroy(): void {\n for (const data of this.datas) {\n data.destroy();\n }\n }\n\n}\n"],"file":"index.js"} |