0e5e8095c69387c7efe850809e783dd98d2001df.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCInteger, Component, error, Sprite, SpriteFrame, _decorator, _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, executeInEditMode, requireComponent, menu, BhvFrameIndex;
  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. CCInteger = _cc.CCInteger;
  13. Component = _cc.Component;
  14. error = _cc.error;
  15. Sprite = _cc.Sprite;
  16. SpriteFrame = _cc.SpriteFrame;
  17. _decorator = _cc._decorator;
  18. }],
  19. execute: function () {
  20. _crd = true;
  21. _cclegacy._RF.push({}, "c238ewfJ2VJnZ8Gb8YQs5Ts", "BhvFrameIndex", undefined);
  22. __checkObsolete__(['CCInteger', 'Component', 'error', 'Sprite', 'SpriteFrame', '_decorator']);
  23. ({
  24. ccclass,
  25. property,
  26. executeInEditMode,
  27. requireComponent,
  28. menu
  29. } = _decorator);
  30. /** 图片切换 */
  31. _export("BhvFrameIndex", BhvFrameIndex = (_dec = requireComponent(Sprite), _dec2 = menu("OopsFramework/UI/Frame Index (图片切换)"), _dec3 = property({
  32. type: [SpriteFrame],
  33. tooltip: 'sprite将会用到帧图片'
  34. }), _dec4 = property({
  35. type: CCInteger,
  36. tooltip: '当前显示的帧图'
  37. }), ccclass(_class = executeInEditMode(_class = _dec(_class = _dec2(_class = (_class2 = class BhvFrameIndex extends Component {
  38. constructor() {
  39. super(...arguments);
  40. _initializerDefineProperty(this, "spriteFrames", _descriptor, this);
  41. _initializerDefineProperty(this, "_index", _descriptor2, this);
  42. }
  43. get index() {
  44. return this._index;
  45. }
  46. set index(value) {
  47. if (value < 0) return;
  48. this._index = value % this.spriteFrames.length;
  49. var sprite = this.node.getComponent(Sprite); //设置 Sprite 组件的spriteFrame属性,变换图片
  50. sprite.spriteFrame = this.spriteFrames[this._index];
  51. }
  52. /** 通过设置帧名字来设置对象 */
  53. setName(name) {
  54. var index = this.spriteFrames.findIndex(v => {
  55. return v.name == name;
  56. });
  57. if (index < 0) {
  58. error('frameIndex 设置了不存在的name:', name);
  59. }
  60. this.index = index || 0;
  61. }
  62. /** 随机范围设置帧图片 */
  63. random(min, max) {
  64. if (!this.spriteFrames) return;
  65. var frameMax = this.spriteFrames.length;
  66. if (min == null || min < 0) min = 0;
  67. if (max == null || max > frameMax) max = frameMax;
  68. this.index = Math.floor(Math.random() * (max - min) + min);
  69. }
  70. next() {
  71. this.index++;
  72. }
  73. previous() {
  74. this.index--;
  75. }
  76. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "spriteFrames", [_dec3], {
  77. configurable: true,
  78. enumerable: true,
  79. writable: true,
  80. initializer: function initializer() {
  81. return [null];
  82. }
  83. }), _applyDecoratedDescriptor(_class2.prototype, "index", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "index"), _class2.prototype), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_index", [property], {
  84. configurable: true,
  85. enumerable: true,
  86. writable: true,
  87. initializer: function initializer() {
  88. return 0;
  89. }
  90. })), _class2)) || _class) || _class) || _class) || _class));
  91. _cclegacy._RF.pop();
  92. _crd = false;
  93. }
  94. };
  95. });
  96. //# sourceMappingURL=0e5e8095c69387c7efe850809e783dd98d2001df.js.map