Class: Chingu::GameStates::Popup
- Inherits:
-
Chingu::GameState
- Object
- Chingu::GameState
- Chingu::GameStates::Popup
- Defined in:
- lib/chingu/game_states/popup.rb
Overview
Premade game state for chingu - A simple way if pausing the game + displaying a text. Usage:
push_game_state(Chingu::GameStates::Popup.new(:text => "bla bla bla"))
TODO: Use Gosu’s new flush() instead of mucking around with ZORDER + 1000…
Constant Summary
Constants included from Helpers::GFX
Instance Attribute Summary
Attributes inherited from Chingu::GameState
#game_objects, #game_state_manager, #options, #previous_game_state
Attributes included from Helpers::InputDispatcher
Instance Method Summary collapse
- #button_up(id) ⇒ Object
- #draw ⇒ Object
-
#initialize(options = {}) ⇒ Popup
constructor
A new instance of Popup.
Methods inherited from Chingu::GameState
#button_down, #close, #close_game, #draw_trait, #filename, #setup, #setup_trait, #to_s, #to_sym, trait, #trait_options, traits, #update, #update_trait
Methods included from Helpers::ClassInheritableAccessor
Methods included from Helpers::InputClient
Methods included from Helpers::InputDispatcher
#add_input_client, #dispatch_action, #dispatch_button_down, #dispatch_button_up, #dispatch_input_for, #remove_input_client
Methods included from Helpers::GameObject
#add_game_object, #game_objects, #game_objects_of_class, #load_game_objects, #remove_game_object, #save_game_objects
Methods included from Helpers::GameState
#clear_game_states, #current_game_state, #game_states, #pop_game_state, #push_game_state, #switch_game_state, #transitional_game_state
Methods included from Helpers::GFX
#draw_circle, #draw_rect, #fill, #fill_gradient, #fill_rect
Constructor Details
#initialize(options = {}) ⇒ Popup
Returns a new instance of Popup.
34 35 36 37 38 39 40 |
# File 'lib/chingu/game_states/popup.rb', line 34 def initialize( = {}) super @white = Color.new(255,255,255,255) @color = Gosu::Color.new(200,0,0,0) @string = [:text] || "Press ESC to return." @text = Text.new(@string, :x => 20, :y => 10, :align => :left, :zorder => Chingu::DEBUG_ZORDER + 1001, :factor => 1) end |
Instance Method Details
#button_up(id) ⇒ Object
42 43 44 |
# File 'lib/chingu/game_states/popup.rb', line 42 def (id) pop_game_state(:setup => false) if id == Gosu::KbEscape # Return the previous game state, dont call setup() end |
#draw ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/chingu/game_states/popup.rb', line 46 def draw previous_game_state.draw # Draw prev game state $window.draw_quad( 0,0,@color, $window.width,0,@color, $window.width,$window.height,@color, 0,$window.height,@color, Chingu::DEBUG_ZORDER + 1000) @text.draw end |