FadeInOutUI.ts 726 B

12345678910111213141516171819202122232425
  1. /** @format */
  2. import {BaseUI} from '../BaseUI'
  3. import {Mgr} from '../../GameControl'
  4. import {UI} from '../../enums/UI'
  5. const {ccclass, property} = cc._decorator
  6. @ccclass
  7. export default class FadeInOutUI extends BaseUI {
  8. onShow(args: any, fromUI: number) {
  9. let sprite = cc.find('sprite', this.node)
  10. let aniTime = 0.3
  11. let fadeAction = args.inOrOut ? cc.fadeIn(aniTime) : cc.fadeOut(aniTime)
  12. sprite.stopAllActions()
  13. sprite.opacity = args.inOrOut ? 0 : 255
  14. cc.tween(sprite)
  15. .then(fadeAction)
  16. .call(() => {
  17. Mgr.ui.hide(UI.FadeInOutUI)
  18. args.aniFinishFuc && args.aniFinishFuc()
  19. })
  20. .start()
  21. }
  22. }