2022-06-20 10:56:40 +08:00

1 line
4.3 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","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","setRegion","SkeletonData","createRegion","Math","floor","random","__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;;;MAEUZ,UAAAa,UAAAC,QAAA;QAAV,IAAAX,QAAAE;QACI,IAAAU,WAAAV,KAAAK,IAAAM,uBAAAC,GAAAC;QACA,IAAAC,kBAAAJ,SAAAK,aAAAC;QACAN,SAAAK,eAAAD;QACAJ,SAAAO,YAAA;QAEAjB,KAAAO,KAAAW,KAAAlB,KAAAK;QAEAL,KAAAE,UAAAiB,GAAA,SAAA;UACI,IAAAC,SAAA7B,GAAA8B,YAAAvB,MAAAO;UACA,IAAAiB,cAAAF,OAAAT,uBAAAC,GAAAC;UACAH,SAAAK,eAAAO,YAAAP,aAAAC;UACAN,SAAAO,YAAA;UAEAnB,MAAAO,IAAAkB,OAAAC,SAAAJ;UACAA,OAAAK,YAAA3B,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAC;UACAP,OAAAQ,KAAA;UACA,IAAA9B,MAAAS,KAAAmB,SAAA,MAAA,GAAA;YACIN,OAAAT,uBAAAC,GAAAC,UAAAgB,sBAAAjB,GAAAC,SAAAiB,mBAAAC;YACAX,OAAAT,uBAAApB,GAAAyC,OAAAC,SAAA;;UAEJnC,MAAAS,KAAAW,KAAAE;;QAGJpB,KAAAG,aAAAgB,GAAA,SAAA;UACI,IAAArB,MAAAS,KAAAmB,SAAA,GAAA;YACI5B,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAQ;YACApC,MAAAS,KAAAmB,UAAA;;;QAIR1B,KAAAI,gBAAAe,GAAA,SAAA;UACI,IAAAd,MAAAP,MAAAS,KAAAT,MAAAS,KAAAmB,SAAA,GAAAf,uBAAAC,GAAAC;UACAR,IAAA8B,UAAA,QAAA,QAAAvB,GAAAwB,aAAAC,aAAAvC,MAAAQ,MAAAgC,KAAAC,MAAAD,KAAAE,WAAA1C,MAAAQ,MAAA;;;MAjDRmC,WAAA,EADC/C,SAAAH,GAAAmD,SACyB/C,UAAAa,WAAA,kBAAA;MAG1BiC,WAAA,EADC/C,SAAAH,GAAAmD,SAC4B/C,UAAAa,WAAA,qBAAA;MAG7BiC,WAAA,EADC/C,SAAAH,GAAAmD,SAC+B/C,UAAAa,WAAA,wBAAA;MAGhCiC,WAAA,EADC/C,SAAAH,GAAAmD,SACmB/C,UAAAa,WAAA,YAAA;MAGpBiC,WAAA,EADC/C,SAAA,EAAAH,GAAAoD,kBAC4BhD,UAAAa,WAAA,cAAA;MAfZb,YAAA8C,WAAA,EADpBhD,WACoBE;MAwDrB,OAAAA;KAxDA,CAAAJ,GAAAqD;IAAqBC,QAAAC,UAAAnD","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 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.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 boySpine.skeletonData = newBoySpine.skeletonData.clone();\n boySpine.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.boys.push(newBoy);\n });\n\n this.removeBoyBtn.on('click', () => {\n if (this.boys.length > 1) {\n this.boys[this.boys.length - 1].destroy();\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.setRegion('Head', 'Head', sp.SkeletonData.createRegion(this.heads[Math.floor(Math.random() * (this.heads.length))]));\n });\n }\n\n}\n"],"file":"index.js"}