123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- 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
|