Class: GamePlay::Base
- Includes:
- DisplayMessage, Input
- Defined in:
- docs/4_Systems_000_General_2_GamePlay__Base.rb,
docs/4_Systems_004_Message.rb
Overview
The base class of every GamePlay scene interface
Add some usefull functions like message display and scene switch and perform the most of the task for you. Generic Process of a GamePlay::Base 1. initialize 1.1 Create the message box (if called by super(false) or super()) 2. main 2.1 main_begin 2.1.1 create_graphics 2.1.2 Graphics.transition (fade in) 2.2 loop { update } 2.3 main_end 2.3.1 Graphics.freeze (fade out) 2.3.2 dispose : grep all the /viewport/ ivar and dispose them 3. update (in GamePlay::BaseCleanUpdate) 3.1 update message 3.2 update inputs (if not locked by message) 3.3 update mouse (if not locked by inputs) 3.4 update graphics (always)
This class is inherited by GamePlay::BaseCleanUpdate
You usually will define your Scene the following way :
class Scene < BaseCleanUpdate
# Create a new scene
# @param args [Array] input arguments (do something better than *args)
def initialize(*args)
super() # <= the () force super to be called without argument because by `super` alone use the method arguments!
# Initialize only the logic here (instance variable used for the state or data used by the UI)
end
# Called when input can be updated (put your input related code inside)
# @return [Boolean] if the update can continue
def update_inputs
# ...
return true
end
# Called when mouse can be updated (put your mouse related code inside, optional)
# @param moved [Boolean] boolean telling if the mouse moved
# @return [Boolean] if the update can continue
def update_mouse(moved)
return unless moved
# ...
return true
end
# Called each frame after message update and eventual mouse/input update
# @return [Boolean] if the update can continue
def update_graphics
# ...
return true
end
private
# Create all the UI and thing related to graphics (super create the viewport)
def create_graphics
create_viewport # Necessary to make the scene work properly
# ...
end
# (optional) Create the viewport (called by create_graphics from Base)
def create_viewport
super # < if you still use main with default settings, otherwise don't call super
@sub_viewport = Viewport.create(...) # < Sub viewport for other stuff
end
end
Note : You don't have to define the dispose function with this. All the viewport that are stored inside ivar will be automatically disposed if the variable name contains viewport.
Direct Known Subclasses
Battle::Scene, Contest::Scene, BaseCleanUpdate, Hatch, StateMachine, Scene_Map
Constant Summary collapse
- DEFAULT_TRANSITION =
Default fade type used to switch between interfaces
:transition- DEFAULT_TRANSITION_PARAMETER =
Parameters of the transition
16
Constants included from Input
Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE
Constants included from DisplayMessage
DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR
Instance Attribute Summary collapse
-
#__last_scene ⇒ Base
readonly
The scene that called this scene (usefull when this scene needs to return to the last scene).
-
#__result_process ⇒ Proc?
The process that is called when the call_scene method returns.
-
#clock ⇒ Clock
readonly
Get the scene clock.
-
#running ⇒ Boolean
If the current scene is still running.
-
#viewport ⇒ Viewport?
readonly
The viewport in which the scene is shown.
Attributes included from DisplayMessage
Instance Method Summary collapse
-
#add_disposable(*args)
Add a disposable object to the "object_to_dispose" array.
-
#call_scene(name, *args, fade_out_params: nil, fade_in_params: nil, **kwarg, &result_process) ⇒ Boolean
Call an other scene.
-
#dispose
Dispose the scene graphics.
-
#find_parent(klass, fallback = self)
Find a parent scene.
-
#initialize(no_message = false, message_z = 20_000, *message_viewport_args) ⇒ Base
constructor
rubocop:disable Style/OptionalBooleanParameter Create a new GamePlay scene.
-
#main
The GamePlay entry point (Must not be overridden).
-
#return_to_scene(name, *args) ⇒ Boolean
Return to an other scene, create the scene if args.size > 0.
-
#snap_to_bitmap ⇒ Texture
Take a snapshot of the scene.
-
#update ⇒ Boolean
Scene update process.
-
#visible ⇒ Boolean
Tell if the scene is visible.
-
#visible=(value)
Change the viewport visibility of the scene.
Methods included from Input
clear, close_virtual_keyboard, dir4, dir8, get_text, joy_axis_position, load_touch_screen, open_virtual_keyboard, press?, register_events, released?, repeat?, swap_states, trigger?
Methods included from DisplayMessage
#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=
Constructor Details
#initialize(no_message = false, message_z = 20_000, *message_viewport_args) ⇒ Base
rubocop:disable Style/OptionalBooleanParameter Create a new GamePlay scene
105 106 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 105 def initialize( = false, = 20_000, *) end |
Instance Attribute Details
#__last_scene ⇒ Base (readonly)
The scene that called this scene (usefull when this scene needs to return to the last scene)
90 91 92 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 90 def __last_scene @__last_scene end |
#__result_process ⇒ Proc?
The process that is called when the call_scene method returns
93 94 95 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 93 def __result_process @__result_process end |
#clock ⇒ Clock (readonly)
Get the scene clock
99 100 101 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 99 def clock @clock end |
#running ⇒ Boolean
If the current scene is still running
96 97 98 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 96 def running @running end |
#viewport ⇒ Viewport? (readonly)
The viewport in which the scene is shown
87 88 89 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 87 def @viewport end |
Instance Method Details
#add_disposable(*args)
Add a disposable object to the "object_to_dispose" array
117 118 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 117 def add_disposable(*args) end |
#call_scene(name, *args, fade_out_params: nil, fade_in_params: nil, **kwarg, &result_process) ⇒ Boolean
Call an other scene
136 137 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 136 def call_scene(name, *args, fade_out_params: nil, fade_in_params: nil, **kwarg, &result_process) end |
#dispose
@viewport and @message_window will be disposed.
Dispose the scene graphics.
113 114 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 113 def dispose end |
#find_parent(klass, fallback = self)
Find a parent scene
153 154 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 153 def find_parent(klass, fallback = self) end |
#main
The GamePlay entry point (Must not be overridden).
120 121 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 120 def main end |
#return_to_scene(name, *args) ⇒ Boolean
This scene will stop running
Return to an other scene, create the scene if args.size > 0
143 144 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 143 def return_to_scene(name, *args) end |
#snap_to_bitmap ⇒ Texture
You have to dispose the bitmap you got from this function
Take a snapshot of the scene
148 149 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 148 def snap_to_bitmap end |
#update ⇒ Boolean
Scene update process
109 110 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 109 def update end |
#visible ⇒ Boolean
Tell if the scene is visible
128 129 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 128 def visible end |
#visible=(value)
Change the viewport visibility of the scene
124 125 |
# File 'docs/4_Systems_000_General_2_GamePlay__Base.rb', line 124 def visible=(value) end |