System.register(["cc"], function (_export, _context) { "use strict"; var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, Color, Component, sp, sys, _decorator, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, SpineView; function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); } return { setters: [function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; Color = _cc.Color; Component = _cc.Component; sp = _cc.sp; sys = _cc.sys; _decorator = _cc._decorator; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "ce889T62SpI8ot39/O0nFrT", "SpineView", undefined); __checkObsolete__(['Color', 'Component', 'sp', 'sys', '_decorator']); ({ ccclass, property } = _decorator); /** * spine动画表现管理 * @author * */ _export("default", SpineView = (_dec = ccclass('SpineView'), _dec2 = property({ displayName: '待机' }), _dec3 = property({ type: sp.Skeleton, tooltip: '角色动画' }), _dec(_class = (_class2 = class SpineView extends Component { constructor() { super(...arguments); this.skin = "default"; _initializerDefineProperty(this, "idle", _descriptor, this); _initializerDefineProperty(this, "spine", _descriptor2, this); this.cur = null; this.OnComp = void 0; this.resetColor = Color.WHITE; } onLoad() { //console.log("111111111111"); //this.spine.enableBatch=false; if (sys.isNative) { //原生共享模式有bug this.spine.setAnimationCacheMode(sp.AnimationCacheMode.REALTIME); this.spine.clearTracks(); //清理所有播放队列的动画 } //this.SetSkin(this.skin); } start() { this.DoAnimation(this.idle, true); this.spine.setCompleteListener(function () { if (this.OnComp) this.OnComp(); }.bind(this)); } onBeforeRemove() { this.spine.setCompleteListener(null); } Dispos() { this.ResetColor(); this.OnComp = null; //this.spine.setCompleteListener(null); } SetSkin(skin) { this.spine.setSkin(skin); } DoAnimation(animation, loop, track, force) { if (loop === void 0) { loop = true; } if (track === void 0) { track = 0; } if (force === void 0) { force = false; } if (force) { this.spine.setAnimation(track, animation, loop); return; } if (this.cur == animation) return; this.spine.setAnimation(track, animation, loop); } /**设置是否暂停 */ SetPaused(paused) { this.spine.paused = paused; } /**获取是否暂停 */ GetPaused() { return this.spine.paused; } CheckPaused(paused) { if (this.spine.paused != paused) this.spine.paused = paused; } /** 闪色表现 Color.RED 0.1*/ Flash(color, time) { if (this.spine.color != color) { this.spine.color = color; this.unscheduleAllCallbacks(); this.scheduleOnce(() => { this.spine.color = this.resetColor; }, time); } } ChangeMagenta() { this.ChangeColor(Color.MAGENTA); } ChangeGreen() { this.ChangeColor(Color.GREEN); } ChangeGray() { this.ChangeColor(Color.GRAY); } ChangeRed() { this.ChangeColor(Color.RED); } ChangeCyan() { this.ChangeColor(Color.CYAN); } ChangeBlack() { this.ChangeColor(Color.BLACK); } ChangeBule() { this.ChangeColor(Color.BLUE); } ChangeYellow() { this.ChangeColor(Color.YELLOW); } // /** 变色表现 Color.RED 0.1*/ ChangeColor(color) { this.resetColor = color; if (this.spine.color != this.resetColor) { this.spine.color = this.resetColor; } } ResetColor() { this.resetColor = Color.WHITE; if (this.spine.color != this.resetColor) { this.spine.color = this.resetColor; } } /** * 缩放动画播放速率 * @override * @param scale 缩放倍率 */ scaleTime(scale) { if (scale > 0) this.spine.timeScale = scale; } getBone(name) { var bone = this.spine.findBone(name); return bone; } /** * 换装 * @param slotName 插槽名字 * @param attachmentName 元素名字 */ changeEquipment(slotName, attachmentName) { if (attachmentName === void 0) { attachmentName = null; } var slot = this.spine.findSlot(slotName); if (slot) { if (attachmentName) { var attachment = this.spine.getAttachment(slotName, attachmentName); slot.setAttachment(attachment); } else { slot.setAttachment(null); } } } /**换装 * @param skinName 要替换的部件皮肤名称 * @param slotName 要替换的部件的插槽名称 * @param targetAttaName Spine中皮肤占位符的名字 */ changeSlot(skinName, slotName, targetAttaName) { //查找局部皮肤 var skeletonData = this.spine.skeletonData.getRuntimeData(); var targetSkin = skeletonData.findSkin(skinName); //查找局部皮肤下的插槽与附件 var targetSkinSlotIndex = skeletonData.findSlotIndex(slotName); var atta = targetSkin.getAttachment(targetSkinSlotIndex, targetAttaName); //查找全身皮肤下的插槽 var curSlot = this.spine.findSlot(slotName); //替换全身皮肤插槽的附件 curSlot && curSlot.setAttachment(atta); } }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "idle", [_dec2], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return ""; } }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "spine", [_dec3], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return null; } })), _class2)) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=20712297188dd3bbe9fb3acc1799edea45dda86b.js.map