b81015ae-719e-4fc2-ab4c-fd12473241ca.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. cc._RF.push(module, 'b8101WucZ5PwqtM/RJHMkHK', 'XButton');
  3. // Script/Manager/XButton.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. // Learn TypeScript:
  26. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  27. // Learn Attribute:
  28. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  29. // Learn life-cycle callbacks:
  30. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  31. var App_1 = require("./App");
  32. var SoundManager_1 = require("./SoundManager");
  33. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  34. var XButton = /** @class */ (function (_super) {
  35. __extends(XButton, _super);
  36. function XButton() {
  37. return _super !== null && _super.apply(this, arguments) || this;
  38. }
  39. XButton.prototype.onLoad = function () {
  40. };
  41. XButton.prototype.onTouchDown = function (event) {
  42. this.playOutAnim();
  43. App_1.App.SoundManager.playEffect(SoundManager_1.SoundManager.click);
  44. };
  45. XButton.prototype.onTouchUp = function (event) {
  46. this.playBackAnim();
  47. };
  48. //播放扩展动画
  49. XButton.prototype.playOutAnim = function () {
  50. cc.tween(this.node).set({ scale: 1 }).to(0.2, { scale: 0.9 }).start();
  51. };
  52. //播放收缩动画
  53. XButton.prototype.playBackAnim = function () {
  54. var _this = this;
  55. cc.tween(this.node).stop();
  56. cc.tween(this.node).to(0.2, { scale: 1 }).call(function () {
  57. cc.tween(_this.node).removeSelf();
  58. }).start();
  59. };
  60. XButton.prototype.start = function () {
  61. this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchUp.bind(this), this.node);
  62. this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchUp.bind(this), this.node);
  63. this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchDown.bind(this), this.node);
  64. };
  65. XButton = __decorate([
  66. ccclass
  67. ], XButton);
  68. return XButton;
  69. }(cc.Component));
  70. exports.default = XButton;
  71. cc._RF.pop();