StarHandbookItem.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const DWTool = require("../utils/DWTool");
  2. const ArtistManager = require("../utils/ArtistManager");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. starDarkNode: cc.Node,
  7. starHeadNode: cc.Node,
  8. countNode: cc.Node,
  9. countLabel: cc.Label,
  10. isUnlocked: {
  11. get: function() {
  12. if (!this._isUnlocked) {
  13. this._isUnlocked = false;
  14. }
  15. return this._isUnlocked;
  16. },
  17. set: function(value) {
  18. this._isUnlocked = value;
  19. if (this._isUnlocked) {
  20. this.starHeadNode.active = true;
  21. this.countNode.active = true;
  22. this.starDarkNode.active = false;
  23. } else {
  24. this.starHeadNode.active = false;
  25. this.countNode.active = false;
  26. this.starDarkNode.active = true;
  27. }
  28. }
  29. },
  30. },
  31. // LIFE-CYCLE CALLBACKS:
  32. onLoad () {
  33. this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  34. this.showStarDesc();
  35. }, 1000, true), this);
  36. },
  37. start () {
  38. },
  39. configData(starInfo) {
  40. this.starInfo = starInfo;
  41. if (starInfo.starCount > 0 ) {
  42. this.isUnlocked = true;
  43. this.countLabel.string = `${starInfo.starCount}/${starInfo.starCount}`;
  44. } else {
  45. this.isUnlocked = false;
  46. }
  47. let imageId = 50000 + starInfo.starId;
  48. ArtistManager.loadStarBlackAvatarSpriteFrame(imageId, this.starDarkNode.getComponent('cc.Sprite'));
  49. ArtistManager.loadStarAvatarSpriteFrame(imageId, this.starHeadNode.getComponent('cc.Sprite'));
  50. },
  51. showStarDesc() {
  52. if (this.isUnlocked) {
  53. GameEvent.fire('show_star_desc', this.starInfo);
  54. }
  55. },
  56. // update (dt) {},
  57. });