BuyTip.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. var Module = require('Module');
  11. cc.Class({
  12. extends: cc.Component,
  13. properties: {
  14. lvLabel: {
  15. default: null,
  16. type: cc.Label
  17. },
  18. earnMoneyLabel: {
  19. default: null,
  20. type: cc.Label
  21. },
  22. costLabel: {
  23. default: null,
  24. type: cc.Label
  25. },
  26. roomSprite: {
  27. default: null,
  28. type: cc.Sprite
  29. },
  30. nameLabel: {
  31. default: null,
  32. type: cc.Label
  33. },
  34. },
  35. // LIFE-CYCLE CALLBACKS:
  36. onLoad () {},
  37. init(room, config, roomSpriteFrame) {
  38. this.room = room;
  39. this.lvLabel.string = "Lv" + (config.lv + 1).toString();
  40. this.earnMoneyLabel.string = config.speed[config.lv].toString();
  41. this.costLabel.string = config.price[config.lv].toString();
  42. this.roomSprite.spriteFrame = roomSpriteFrame;
  43. this.nameLabel.string = config.name;
  44. },
  45. clickCloseButton: function () {
  46. let callBack = cc.callFunc(function () {
  47. Module.game.getComponent('game').setBuyTipNode(null);
  48. this.node.destroy();
  49. }, this);
  50. this.closeAnimation(callBack);
  51. },
  52. clickUpdateButton: function () {
  53. let callBack = cc.callFunc(function () {
  54. this.room.getComponent('room').updateAnimation();
  55. Global.GameEvent.fire("room_update", this.room);
  56. this.node.destroy();
  57. }, this);
  58. this.closeAnimation(callBack);
  59. },
  60. closeAnimation: function (callBack) {
  61. if (callBack !== undefined) {
  62. let action = cc.scaleTo(0.2, 0, 0).easing(cc.easeOut(0.95));
  63. this.node.runAction(cc.sequence(action, callBack));
  64. }
  65. },
  66. // update (dt) {},
  67. });