FortuneGiftLayer.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import SoundMgr from "../base/SoundMgr";
  2. var baseLayer = require('BaseLayer');
  3. cc.Class({
  4. extends: baseLayer,
  5. properties: {
  6. gunNodes: [cc.Node],
  7. togNodes: [cc.Node],
  8. labNum: cc.Label,
  9. labLv: cc.Label,
  10. labNaxia: cc.Label,
  11. acNode: cc.Node,
  12. },
  13. // LIFE-CYCLE CALLBACKS:
  14. // onLoad () {},
  15. start () {
  16. this.init();
  17. this.beginGun();
  18. this.selectToggle(null, 0);
  19. },
  20. init(){
  21. for(let i=0; i< this.togNodes.length; i++){
  22. cc.find('off/labzi', this.togNodes[i]).getComponent(cc.Label).string = `${80}元`;
  23. cc.find('on/labzi', this.togNodes[i]).getComponent(cc.Label).string = `${80}元`;
  24. }
  25. this.acNode.getComponent('RechargeActivity').setType(0, this);
  26. },
  27. beginGun(){
  28. for(let i=0; i < this.gunNodes.length; i++){
  29. cc.tween(this.gunNodes[i])
  30. .sequence(
  31. cc.tween().by(0.5, {y: 30}),
  32. cc.tween().call(()=>{
  33. if(this.gunNodes[i].y == 45){ //重置
  34. this.gunNodes[i].y = -45;
  35. let str = `<color=#F6ECD8>恭喜“</c><color=#E9E61E>${123}</c><color=#F6ECD8>”购买</c><color=#C45558>"${2000}元鸿运礼包</c><color=#F6ECD8>幸运得</c><color=#E9E61E>${88888888}</c>`;
  36. this.gunNodes[i].getComponent(cc.RichText).string = str;
  37. }
  38. }),
  39. // cc.tween().delay(1)
  40. )
  41. .repeatForever()
  42. .start()
  43. }
  44. },
  45. selectToggle(event, index){ //0 1 2 3 4 5
  46. for(let i=0; i < this.togNodes.length; i++){
  47. this.togNodes[i].getChildByName('on').active = false;
  48. }
  49. this.togNodes[index].getChildByName('on').active = true;
  50. this.labNum.string = '2万~4万';
  51. this.labLv.string = '200%';
  52. this.labNaxia.string = `${234}元立即拿下`;
  53. },
  54. onClickNaxia(){
  55. SoundMgr.playClick();
  56. }
  57. });