b338d43f47dfc4fb7dece127fe5d88d8c0b856eb.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCString, Color, Component, sp, _decorator, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, UISpineMovie;
  4. 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 }); }
  5. 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; }
  6. 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.'); }
  7. return {
  8. setters: [function (_cc) {
  9. _cclegacy = _cc.cclegacy;
  10. __checkObsolete__ = _cc.__checkObsolete__;
  11. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  12. CCString = _cc.CCString;
  13. Color = _cc.Color;
  14. Component = _cc.Component;
  15. sp = _cc.sp;
  16. _decorator = _cc._decorator;
  17. }],
  18. execute: function () {
  19. _crd = true;
  20. _cclegacy._RF.push({}, "4ce979zctxD67dYVnpW4Mn+", "UISpineMovie", undefined);
  21. __checkObsolete__(['CCString', 'Color', 'Component', 'sp', '_decorator']);
  22. ({
  23. ccclass,
  24. property
  25. } = _decorator);
  26. /**
  27. * spine动画表现管理
  28. * @author
  29. */
  30. _export("default", UISpineMovie = (_dec = ccclass('UISpineMovie'), _dec2 = property({
  31. type: [CCString],
  32. displayName: '动画列表'
  33. }), _dec3 = property({
  34. type: sp.Skeleton,
  35. tooltip: '角色动画'
  36. }), _dec(_class = (_class2 = class UISpineMovie extends Component {
  37. constructor() {
  38. super(...arguments);
  39. _initializerDefineProperty(this, "animat_names", _descriptor, this);
  40. _initializerDefineProperty(this, "spine", _descriptor2, this);
  41. this.cur = null;
  42. this.index = 0;
  43. }
  44. onLoad() {}
  45. start() {
  46. //this.spine.clearTracks()
  47. /*this.spine.setStartListener(function(){
  48. console.log("动画开始")
  49. }.bind(this));*/
  50. /* this.spine.setEventListener(((trackEntry:any, event:any) => {
  51. //var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  52. //console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
  53. this.unit.DoEvent(event.data.name);
  54. }) as any);*/
  55. //
  56. //let duration = this.spine.getCurrent(0).animation.duration;
  57. //let frames = Math.ceil(frameRate * duration);
  58. //let secondsPerFrame = 1 / frameRate;
  59. //`总帧数 ${this.frames}`;
  60. //this.spine.setCompleteListener(trackEntry => {
  61. //});
  62. if (this.animat_names.length > 0) {
  63. this.index = 0;
  64. if (this.index == this.animat_names.length - 1) {
  65. this.DoAnimation(this.animat_names[this.index], true);
  66. } else {
  67. this.DoAnimation(this.animat_names[this.index], false);
  68. }
  69. this.spine.setCompleteListener(function () {
  70. this.index++;
  71. if (this.index < this.animat_names.length) {
  72. if (this.index == this.animat_names.length - 1) {
  73. this.DoAnimation(this.animat_names[this.index], true);
  74. } else {
  75. this.DoAnimation(this.animat_names[this.index], false);
  76. }
  77. } else {
  78. this.spine.setCompleteListener(null);
  79. }
  80. }.bind(this));
  81. }
  82. }
  83. SetSkin(skin) {
  84. this.spine.setSkin(skin);
  85. }
  86. DoAnimation(animation, loop, track, force) {
  87. if (loop === void 0) {
  88. loop = true;
  89. }
  90. if (track === void 0) {
  91. track = 0;
  92. }
  93. if (force === void 0) {
  94. force = false;
  95. }
  96. if (force) {
  97. this.spine.setAnimation(track, animation, loop);
  98. return;
  99. }
  100. if (this.cur == animation) return;
  101. this.spine.setAnimation(track, animation, loop);
  102. }
  103. /**设置是否暂停 */
  104. SetPaused(paused) {
  105. this.spine.paused = paused;
  106. }
  107. /**获取是否暂停 */
  108. GetPaused() {
  109. return this.spine.paused;
  110. }
  111. CheckPaused(paused) {
  112. if (this.spine.paused != paused) this.spine.paused = paused;
  113. }
  114. /** 闪色表现 Color.RED 0.1*/
  115. Flash(color, time, reColor) {
  116. if (reColor === void 0) {
  117. reColor = Color.WHITE;
  118. }
  119. if (this.spine.color != color) {
  120. this.spine.color = color;
  121. this.unscheduleAllCallbacks();
  122. this.scheduleOnce(() => {
  123. this.spine.color = reColor;
  124. }, time);
  125. }
  126. }
  127. /**
  128. * 缩放动画播放速率
  129. * @override
  130. * @param scale 缩放倍率
  131. */
  132. scaleTime(scale) {
  133. if (scale > 0) this.spine.timeScale = scale;
  134. }
  135. getBone(name) {
  136. var bone = this.spine.findBone(name);
  137. return bone;
  138. }
  139. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "animat_names", [_dec2], {
  140. configurable: true,
  141. enumerable: true,
  142. writable: true,
  143. initializer: function initializer() {
  144. return [];
  145. }
  146. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "spine", [_dec3], {
  147. configurable: true,
  148. enumerable: true,
  149. writable: true,
  150. initializer: function initializer() {
  151. return null;
  152. }
  153. })), _class2)) || _class));
  154. _cclegacy._RF.pop();
  155. _crd = false;
  156. }
  157. };
  158. });
  159. //# sourceMappingURL=b338d43f47dfc4fb7dece127fe5d88d8c0b856eb.js.map