123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, CCFloat, CCInteger, Component, easing, Enum, tween, Vec3, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _crd, ccclass, property, AnimationType, BounceAnimation;
- 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__;
- _decorator = _cc._decorator;
- CCFloat = _cc.CCFloat;
- CCInteger = _cc.CCInteger;
- Component = _cc.Component;
- easing = _cc.easing;
- Enum = _cc.Enum;
- tween = _cc.tween;
- Vec3 = _cc.Vec3;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "80b6b2umTRJgp27pHM6FB3M", "BounceAnimation", undefined);
- __checkObsolete__(['_decorator', 'CCFloat', 'CCInteger', 'Component', 'easing', 'Enum', 'tween', 'Vec3']);
- ({
- ccclass,
- property
- } = _decorator);
- AnimationType = /*#__PURE__*/function (AnimationType) {
- AnimationType[AnimationType["BOUNCE"] = 0] = "BOUNCE";
- AnimationType[AnimationType["BREATHE"] = 1] = "BREATHE";
- return AnimationType;
- }(AnimationType || {});
- _export("BounceAnimation", BounceAnimation = (_dec = ccclass('BounceAnimation'), _dec2 = property({
- type: Enum(AnimationType),
- tooltip: '动画类型'
- }), _dec3 = property({
- type: CCInteger,
- tooltip: '缓动高度',
- visible() {
- return this.animationType === AnimationType.BOUNCE;
- }
- }), _dec4 = property({
- type: CCInteger,
- tooltip: '缓动时间(秒)',
- visible() {
- return this.animationType === AnimationType.BOUNCE;
- }
- }), _dec5 = property({
- type: CCFloat,
- tooltip: '缩放幅度',
- visible() {
- return this.animationType === AnimationType.BREATHE;
- }
- }), _dec6 = property({
- type: CCInteger,
- tooltip: '呼吸周期(秒)',
- visible() {
- return this.animationType === AnimationType.BREATHE;
- }
- }), _dec(_class = (_class2 = class BounceAnimation extends Component {
- constructor() {
- super(...arguments);
- _initializerDefineProperty(this, "animationType", _descriptor, this);
- //弹跳动画参数
- _initializerDefineProperty(this, "bounceHeight", _descriptor2, this);
- _initializerDefineProperty(this, "duration", _descriptor3, this);
- //呼吸动画参数
- _initializerDefineProperty(this, "scaleSize", _descriptor4, this);
- _initializerDefineProperty(this, "breatheDuration", _descriptor5, this);
- this.originalPosition = new Vec3();
- this.originalScale = new Vec3();
- }
- // 新增原始缩放值记录
- start() {
- this.originalPosition = this.node.position.clone();
- this.originalScale = this.node.scale.clone(); // 记录原始缩放值
- this.startAnimation();
- }
- /**
- * 开始执行动画
- */
- startAnimation() {
- var btn_play = this.node;
- if (this.animationType === AnimationType.BOUNCE) {
- tween(btn_play).delay(Math.random()).to(this.duration, {
- position: new Vec3(this.originalPosition.x, this.originalPosition.y + this.bounceHeight, this.originalPosition.z)
- }, {
- easing: easing.linear
- }) // 向上缓动
- .to(this.duration, {
- position: new Vec3(this.originalPosition.x, this.originalPosition.y - this.bounceHeight, this.originalPosition.z)
- }, {
- easing: easing.linear
- }) // 向下缓动
- .to(this.duration, {
- position: new Vec3(this.originalPosition.x, this.originalPosition.y, this.originalPosition.z)
- }, {
- easing: easing.linear
- }) // 向下缓动
- .union().repeatForever() // 无限循环
- .start(); // 启动动画
- } else if (this.animationType === AnimationType.BREATHE) {
- tween(btn_play).sequence(tween().to(this.breatheDuration, {
- scale: new Vec3(this.originalScale.x + this.scaleSize, this.originalScale.y + this.scaleSize, 1)
- }), tween().to(this.breatheDuration, {
- scale: this.originalScale
- })).repeatForever().start();
- }
- }
- }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "animationType", [_dec2], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return AnimationType.BOUNCE;
- }
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "bounceHeight", [_dec3], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return 20;
- }
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "duration", [_dec4], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return 0.5;
- }
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "scaleSize", [_dec5], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return 0.05;
- }
- }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "breatheDuration", [_dec6], {
- configurable: true,
- enumerable: true,
- writable: true,
- initializer: function initializer() {
- return 1;
- }
- })), _class2)) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=dfcefa4c3af6d47d1429be6953fb6dd37d582e77.js.map
|