ExchangeLayer.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import SoundMgr from "../base/SoundMgr";
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. backNode: cc.Node,
  6. itemPrefab: cc.Node,
  7. scroNode: cc.Node,
  8. viewNode: cc.Node,
  9. conNode: cc.Node,
  10. recordNode: cc.Node,
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. onLoad () {
  14. this.adaptor();
  15. },
  16. start () {
  17. this.initItems();
  18. },
  19. initItems(){
  20. this.conNode.removeAllChildren();
  21. for(let i=0; i < 7; i++){
  22. let temp = cc.instantiate(this.itemPrefab);
  23. temp.setParent(this.conNode);
  24. temp.name = `item${i}`;
  25. temp.active = true;
  26. temp.getComponent('ExchangeItem').setInfo(this, 'sss');
  27. }
  28. },
  29. showExchange(hallSceneJs){
  30. this.hallSceneJs = hallSceneJs;
  31. this.node.active = true;
  32. },
  33. onClickRecord(){
  34. this.recordNode.active = true;
  35. },
  36. adaptor(){ //220
  37. let backWPos = this.backNode.convertToWorldSpaceAR(cc.v2(0,0));
  38. let lerp = (backWPos.y -220) * 2;
  39. this.scroNode.setContentSize(this.scroNode.width, this.scroNode.height + lerp);
  40. this.viewNode.setContentSize(this.viewNode.width, this.viewNode.height + lerp);
  41. },
  42. onClose(){
  43. SoundMgr.playClick();
  44. this.node.active = false;
  45. this.hallSceneJs.showHides(true);
  46. },
  47. });