fade.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. if UiContainer == nil then UiContainer = {} end
  2. UiContainer.Fade = {
  3. fade_in = function( self )
  4. local fade = ui_manager:get_widget( "Fade.Screen" )
  5. fade:play_animation_stop( "FadeIn" )
  6. fade:animation_sync()
  7. return 0;
  8. end,
  9. --- Transition from the field or the world map to the battle in Battle.pending_id.
  10. --
  11. -- The screen flashes white and the battle starts under the flash, which BattleUi.show reveals.
  12. battle_transition = function( self )
  13. -- The player can't move during the transition. It's unlocked when the battle ends, unless
  14. -- the player was already locked.
  15. Battle.locked_by_transition = not entity_manager:is_player_locked()
  16. player_lock( true )
  17. local fade = ui_manager:get_widget( "Fade.Screen" )
  18. fade:set_colour( 1, 1, 1 )
  19. fade:play_animation_stop( "BattleFlash" )
  20. fade:animation_sync()
  21. battle_manager:start_battle( Battle.pending_id )
  22. -- The battle takes over the screen, so the cover of the field goes away.
  23. fade:set_alpha( 0 )
  24. fade:set_colour( 0, 0, 0 )
  25. UiContainer.BattleUi.show( UiContainer.BattleUi )
  26. return 0
  27. end,
  28. fade_out = function( self )
  29. local fade = ui_manager:get_widget( "Fade.Screen" )
  30. fade:play_animation_stop( "FadeOut" )
  31. fade:animation_sync()
  32. return 0;
  33. end,
  34. }