UIMain.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Widget, _decorator, Node, PageView, tween, v3 } from 'cc';
  2. import { UIBase } from '../scriptBase/UIBase';
  3. import { UI } from '../enum/UI';
  4. import { GameMgr } from '../manager/GameMgr';
  5. import { CoinItem } from '../uiItem/CoinItem';
  6. import { CoinMgr } from '../manager/CoinMgr';
  7. import { AudioMgr } from '../manager/AudioMgr';
  8. const { ccclass, property, requireComponent } = _decorator;
  9. @ccclass('UI/UIMain')
  10. @requireComponent(Widget)
  11. export class UIMain extends UIBase {
  12. private pageView: PageView = null
  13. private coinItem: CoinItem = null
  14. private hand: Node = null
  15. protected onLoad(): void {
  16. this.pageView = this.findComp('PageView', PageView)
  17. this.coinItem = this.findComp('CoinItem', CoinItem)
  18. this.hand = this.findNode('Tip/Hand')
  19. }
  20. protected start(): void {
  21. tween(this.hand).to(1, { position: v3(200, 0, 0) }).to(1, { position: v3(-200, 0, 0) }).union().repeatForever().start()
  22. }
  23. public onOpen(data?: any): void {
  24. this.pageView.scrollToPage(GameMgr.mode, 0)
  25. this.coinItem.init(CoinMgr.CurCoin)
  26. AudioMgr.playBgm('主界面音乐')
  27. }
  28. public onClose(data?: any): void {
  29. }
  30. protected onBtnSettingClick(): void {
  31. this.open(UI.Setting)
  32. }
  33. protected onBtnLuckySpinClick(): void {
  34. this.open(UI.LuckySpin)
  35. }
  36. protected onBtnPassRewardClick(): void {
  37. this.open(UI.PassReward)
  38. }
  39. }