villageAndMayor.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * 村长镇长信息面板
  3. */
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. title: {
  8. default: null,
  9. type: cc.Node,
  10. serializable: true,
  11. },
  12. infoButton: {
  13. default: null,
  14. type: cc.Node,
  15. serializable: true,
  16. },
  17. content: {
  18. default: null,
  19. type: cc.Label,
  20. serializable: true,
  21. },
  22. callback: {
  23. default: null,
  24. visible: false
  25. },
  26. confirmLabel: {
  27. default: null,
  28. type: cc.Label,
  29. serializable: true,
  30. },
  31. villageInfoTitleText:{
  32. default: null,
  33. tip: "村长面板文字图片",
  34. type: cc.SpriteFrame,
  35. serializable: true,
  36. },
  37. villageInfoButton:{
  38. default: null,
  39. tip: "村长按钮图片",
  40. type: cc.SpriteFrame,
  41. serializable: true,
  42. },
  43. },
  44. /**
  45. * 设置面板信息
  46. */
  47. setVillageAndMayorInfo(context) {
  48. //let { title, content, confirmText, callback } = context;
  49. let {content, confirmText, callback ,type} = context;
  50. this.node.active = true;
  51. this.callback = callback;
  52. //this.title.string = title;
  53. this.content.string = content;
  54. // this.confirmLabel.string = confirmText;
  55. // console.log(type);
  56. if(type == "village"){
  57. this.title.getComponent(cc.Sprite).spriteFrame = this.villageInfoTitleText;
  58. this.infoButton.getComponent(cc.Sprite).spriteFrame = this.villageInfoButton;
  59. }
  60. },
  61. onConfirm(e) {
  62. if (this.callback)
  63. this.callback(e);
  64. },
  65. onCancel(e) {
  66. this.node.active = false;
  67. }
  68. });