InviteFriends.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import InviteItem from "./InviteItem";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class InviteFriends extends cc.Component{
  5. @property({displayName: '已有金额', type: cc.Label})
  6. private lbl_value: cc.Label = null;
  7. @property({displayName: '进度条', type: cc.Sprite})
  8. private sp_progress: cc.Sprite = null;
  9. @property({displayName: '邀请红点', type: cc.Node})
  10. private node_redPoint: cc.Node = null;
  11. @property({displayName: '气泡头像', type: cc.Node})
  12. private node_inviteItem: cc.Node[] = [];
  13. @property({displayName: '红包飞行终点节点', type: cc.Node})
  14. private node_end: cc.Node = null;
  15. private mat_progress: cc.MaterialVariant = null;
  16. private progress: number = 0.5;
  17. onLoad(){
  18. this.mat_progress = this.sp_progress.getMaterials()[0];
  19. this.progress = this.mat_progress.getProperty('offset', 0);
  20. cc.systemEvent.on('keydown', this.onKeyDown, this);
  21. }
  22. start(){
  23. let data = [{}, {}, {},{}, {}, {}, {}];
  24. let length = this.node_inviteItem.length;
  25. for(let i = 0; i != length; ++i)
  26. {
  27. if(i < data.length)
  28. {
  29. let item = this.node_inviteItem[i].getComponent(InviteItem);
  30. item.setItemData(data[i], this.node_end);
  31. }else{
  32. this.node_inviteItem[i].active = false;
  33. }
  34. }
  35. }
  36. //一键领取按钮
  37. private onClickGetAllRewardBtn()
  38. {
  39. mk.audio.playEffect("button");
  40. }
  41. //好友详情按钮
  42. private onClickFriendsBtn()
  43. {
  44. mk.audio.playEffect("button");
  45. }
  46. //规则说明按钮
  47. private onClickRuleBtn()
  48. {
  49. mk.audio.playEffect("button");
  50. }
  51. //邀请好友按钮
  52. private onClickInviteFriendsBtn()
  53. {
  54. mk.audio.playEffect("button");
  55. }
  56. //提现按钮
  57. private onClickCashOutBtn()
  58. {
  59. mk.audio.playEffect("button");
  60. }
  61. private onClickClose(){
  62. mk.audio.playEffect("closeButton");
  63. }
  64. private onKeyDown(key: cc.Event.EventKeyboard)
  65. {
  66. if(key.keyCode == cc.macro.KEY.up)
  67. {
  68. this.progress -= 0.1;
  69. if(this.progress < 0)
  70. this.progress = 0;
  71. this.mat_progress.setProperty('offset', this.progress);
  72. }else if(key.keyCode == cc.macro.KEY.down)
  73. {
  74. this.progress += 0.1;
  75. if(this.progress> 1)
  76. this.progress = 1;
  77. this.mat_progress.setProperty('offset', this.progress);
  78. }
  79. }
  80. onDestroy(){
  81. cc.systemEvent.off('keydown', this.onKeyDown, this);
  82. }
  83. }