CityItem.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. cityPic: cc.Sprite,
  5. current: cc.Node,
  6. locked: cc.Node,
  7. nameLabel: cc.Label,
  8. },
  9. // onLoad () {},
  10. init(info) {
  11. cc.loader.loadRes('./map/' + info.picId, cc.SpriteFrame, (err, spriteFrame) => {
  12. this.cityPic.spriteFrame = spriteFrame;
  13. });
  14. this.nameLabel.string = info.name;
  15. if (info.selected) {
  16. this.current.active = true;
  17. this.locked.active = false;
  18. this.cityPic.node.active = false;
  19. } else if (info.unlock) {
  20. this.current.active = false;
  21. this.locked.active = false;
  22. this.cityPic.node.active = true;
  23. } else {
  24. this.cityPic.node.active = false;
  25. this.current.active = false;
  26. this.locked.active = true;
  27. }
  28. },
  29. start() {
  30. },
  31. fakeLock() {
  32. this.current.active = false;
  33. this.locked.active = true;
  34. this.cityPic.node.active = false;
  35. },
  36. fakeUnLock() {
  37. this.current.active = true;
  38. this.locked.active = false;
  39. this.cityPic.node.active = false;
  40. },
  41. fakeCurrent(){
  42. this.current.active = true;
  43. this.locked.active = false;
  44. this.cityPic.node.active = false;
  45. },
  46. showFinishAnimation(cb) {
  47. this.current.active = false;
  48. this.locked.active = false;
  49. this.cityPic.node.active = true;
  50. this.cityPic.node.setScale(0);
  51. let end = cc.callFunc(() => {
  52. this.current.active = false;
  53. cb();
  54. }, this);
  55. let scale = cc.sequence(cc.scaleTo(0.3, 1, 1).easing(cc.easeBackOut()), end);
  56. this.cityPic.node.runAction(scale);
  57. },
  58. // update (dt) {},
  59. });