FlagClick.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. tag:-1
  5. },
  6. start()
  7. {
  8. this.chooseFlag = cc.find('Canvas/ChooseFlag');
  9. this.flagListScp = this.chooseFlag.getComponent('FlagList');
  10. },
  11. selectFlag(event, customEventData)
  12. {
  13. // console.log('111111')
  14. let node = event.target;
  15. let stroke = node.getChildByName('Stroke');
  16. stroke.active=true;
  17. let confirmBtn = node.getChildByName('Confirm');
  18. confirmBtn.active=true;
  19. if(this.flagListScp.lastSelectNode)
  20. {
  21. this.flagListScp.lastSelectNode.getChildByName('Stroke').active=false;
  22. this.flagListScp.lastSelectNode.getChildByName('Confirm').active=false;
  23. }
  24. this.flagListScp.lastSelectNode = node;
  25. },
  26. confirm()
  27. {
  28. this.flagListScp.flagSp.getComponent(cc.Sprite).spriteFrame = this.flagListScp.lastSelectNode.getChildByName('Sprite').getComponent(cc.Sprite).spriteFrame;
  29. this.chooseFlag.active = false;
  30. }
  31. });