PowerUpLayer.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import ResMgr from "../base/ResMgr";
  2. import SoundMgr from "../base/SoundMgr";
  3. var baseLayer = require('BaseLayer');
  4. cc.Class({
  5. extends: baseLayer,
  6. properties: {
  7. atlasVIP: cc.SpriteAtlas, //vip图集
  8. spVIP: cc.Sprite,
  9. labUp: cc.Label,
  10. labAtk: cc.Label,
  11. spS: cc.Sprite,
  12. leftArrow: cc.Node,
  13. rightArrow: cc.Node,
  14. itemsNode: [cc.Node],
  15. labPay: cc.Label,
  16. togsNode: [cc.Node],
  17. },
  18. // LIFE-CYCLE CALLBACKS:
  19. // onLoad () {},
  20. start () {
  21. this.upvipLv = 1; //直升的VIP
  22. this.curIndex = 0; //当前项
  23. this.atkArr = [];
  24. this.selectToggle(null, 0);
  25. },
  26. selectToggle(event, index){
  27. if(index)
  28. this.curIndex = index;
  29. for(let i=0; i < this.togsNode.length; i++){
  30. this.togsNode[i].getChildByName('on').active = false;
  31. }
  32. this.togsNode[index].getChildByName('on').active = true;
  33. this.leftArrow.active = this.curIndex != 0;
  34. this.rightArrow.active = this.curIndex != 4;
  35. this.setInfos();
  36. },
  37. setInfos(){
  38. this.spVIP.spriteFrame = this.atlasVIP.getSpriteFrame(`VIP${this.upvipLv}`);
  39. this.labUp.string = `直升VIP${this.upvipLv}`;
  40. this.labAtk.string = '888';
  41. ResMgr.loadTexture('texture/vipIcon/s2', (spFrame)=>{
  42. this.spS.spriteFrame = spFrame;
  43. });
  44. this.labPay.string = `${123}元购买`;
  45. for(let i=0; i < this.itemsNode.length; i++){
  46. let sp = this.itemsNode[i].getChildByName('sp').getComponent(cc.Sprite);
  47. ResMgr.loadTexture('texture/resIcon/9005', (spFrame)=>{
  48. sp.spriteFrame = spFrame;
  49. });
  50. this.itemsNode[i].getChildByName('zeng').active = false;
  51. this.itemsNode[i].getChildByName('labDes').getComponent(cc.Label).string = 'x112233';
  52. }
  53. },
  54. onClickLeft(){
  55. SoundMgr.playClick();
  56. this.selectToggle(null, this.curIndex - 1);
  57. },
  58. onClickRight(){
  59. SoundMgr.playClick();
  60. this.selectToggle(null, this.curIndex + 1);
  61. },
  62. onClickPay(){
  63. SoundMgr.playClick();
  64. },
  65. });