Advertisement
FlipelyFlip

$Scene Manager

Jan 25th, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. #==============================================================================
  2. # ** SceneManager
  3. #------------------------------------------------------------------------------
  4. # This module manages scene transitions. For example, it can handle
  5. # hierarchical structures such as calling the item screen from the main menu
  6. # or returning from the item screen to the main menu.
  7. #==============================================================================
  8.  
  9. module SceneManager
  10. #--------------------------------------------------------------------------
  11. # * Module Instance Variables
  12. #--------------------------------------------------------------------------
  13. $scene = nil # current scene object
  14. @stack = [] # stack for hierarchical transitions
  15. @background_bitmap = nil # background bitmap
  16. #--------------------------------------------------------------------------
  17. # * Execute
  18. #--------------------------------------------------------------------------
  19. def self.run
  20. DataManager.init
  21. Audio.setup_midi if use_midi?
  22. $scene = first_scene_class.new
  23. $scene.main while $scene
  24. end
  25. #--------------------------------------------------------------------------
  26. # * Get First Scene Class
  27. #--------------------------------------------------------------------------
  28. def self.first_scene_class
  29. $BTEST ? Scene_Battle : Scene_Title
  30. end
  31. #--------------------------------------------------------------------------
  32. # * Use MIDI?
  33. #--------------------------------------------------------------------------
  34. def self.use_midi?
  35. $data_system.opt_use_midi
  36. end
  37. #--------------------------------------------------------------------------
  38. # * Get Current Scene
  39. #--------------------------------------------------------------------------
  40. def self.scene
  41. $scene
  42. end
  43. #--------------------------------------------------------------------------
  44. # * Determine Current Scene Class
  45. #--------------------------------------------------------------------------
  46. def self.scene_is?(scene_class)
  47. $scene.instance_of?(scene_class)
  48. end
  49. #--------------------------------------------------------------------------
  50. # * Direct Transition
  51. #--------------------------------------------------------------------------
  52. def self.goto(scene_class)
  53. $scene = scene_class.new
  54. end
  55. #--------------------------------------------------------------------------
  56. # * Call
  57. #--------------------------------------------------------------------------
  58. def self.call(scene_class)
  59. @stack.push($scene)
  60. $scene = scene_class.new
  61. end
  62. #--------------------------------------------------------------------------
  63. # * Return to Caller
  64. #--------------------------------------------------------------------------
  65. def self.return
  66. $scene = @stack.pop
  67. end
  68. #--------------------------------------------------------------------------
  69. # * Clear Call Stack
  70. #--------------------------------------------------------------------------
  71. def self.clear
  72. @stack.clear
  73. end
  74. #--------------------------------------------------------------------------
  75. # * Exit Game
  76. #--------------------------------------------------------------------------
  77. def self.exit
  78. $scene = nil
  79. end
  80. #--------------------------------------------------------------------------
  81. # * Create Snapshot to Use as Background
  82. #--------------------------------------------------------------------------
  83. def self.snapshot_for_background
  84. @background_bitmap.dispose if @background_bitmap
  85. @background_bitmap = Graphics.snap_to_bitmap
  86. @background_bitmap.blur
  87. end
  88. #--------------------------------------------------------------------------
  89. # * Get Background Bitmap
  90. #--------------------------------------------------------------------------
  91. def self.background_bitmap
  92. @background_bitmap
  93. end
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement