Content_Button.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. Name: {
  5. default: '',
  6. tooltip: '建筑名称',
  7. },
  8. Price: {
  9. default: '',
  10. tooltip: '需要金币的价格',
  11. },
  12. DiamondPrice: {
  13. default: 1,
  14. type:cc.Integer,
  15. tooltip: '需要钻石的价格',
  16. },
  17. Synopsis: {
  18. default: '',
  19. tooltip: '简介',
  20. },
  21. Sprite: {
  22. default: null,
  23. tooltip: '对应图片组件',
  24. type: cc.Sprite
  25. },
  26. clickEvents: {
  27. default: [],
  28. type: cc.Component.EventHandler,
  29. tooltip: CC_DEV && 'i18n:COMPONENT.button.click_events',
  30. }
  31. },
  32. onPressed() {
  33. let NameNode = this.node.getChildByName('Name');
  34. if (NameNode) {
  35. let Num = NameNode.getChildByName('Num');
  36. if (Num) {
  37. let NumLabel = Num.getComponent(cc.Label);
  38. // cc.log('NumLabel='+NumLabel.string);
  39. if (parseInt(NumLabel.string) < 1) {
  40. //this is Content_Button
  41. GlobalD.game._ManageUIScript.onPurchaseTips(this);
  42. return;
  43. }
  44. }
  45. }
  46. // GlobalD.game._ManageUIScript.onPurchaseTips(this.node.name);
  47. // return;
  48. GlobalD.game._ManageUIScript.onSetButtonState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
  49. },
  50. onPressedInfo(event, customEventData) {
  51. GlobalD.game._ManageUIScript.onSetButtonInfoState({ Target: this }, { Name: this.Name, Price: this.Price, Synopsis: this.Synopsis });
  52. }
  53. });