Class: Carbuncle::Game
- Defined in:
- gems/carbuncle-core/mrblib/game.rb
Constant Summary
Constants included from Enumerable
Instance Attribute Summary collapse
-
#current_game ⇒ Carbuncle::Game
readonly
The current game, that’s already running.
Lifecycle methods collapse
-
#load ⇒ nil
This method is called before the graphics context are created.
-
#start ⇒ nil
This method is called after the graphics context is created and assets were prepared.
Lifecycle events collapse
-
#after_close ⇒ nil
This event is called after the game is closed and the screen is destroyed.
-
#after_run ⇒ nil
This event is called after the game starts, even after load.
-
#before_close ⇒ nil
This event is called before the game is closed, useful for cleanup.
-
#before_run ⇒ nil
This event is called before the game starts, even before the screen is initialized.
-
#file_dropped(*files) ⇒ nil
This method is called when a file is dropped.
-
#on_resize(width, height) ⇒ nil
Called on the web when the canvas resizes.
Instance Method Summary collapse
-
#running? ⇒ Boolean
Returns true if a game is running.
Methods inherited from Container
#add_child, #add_children, #children, #draw, #each, #initialize, #remove_child, #remove_children, #update
Methods included from Enumerable
__update_hash, #all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #sum, #take, #take_while, #tally, #to_h, #uniq, #zip
Constructor Details
This class inherits a constructor from Carbuncle::Container
Instance Attribute Details
#current_game ⇒ Carbuncle::Game (readonly)
The current game, that’s already running.
|
# File 'gems/carbuncle-core/mrblib/game.rb', line 4
|
Instance Method Details
#after_close ⇒ nil
This event is called after the game is closed and the screen is destroyed.
66 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 66 def after_close; end |
#after_run ⇒ nil
This event is called after the game starts, even after load. You can use this event to trigger your start, if you want to keep it separated from load.
58 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 58 def after_run; end |
#before_close ⇒ nil
This event is called before the game is closed, useful for cleanup.
62 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 62 def before_close; end |
#before_run ⇒ nil
This event is called before the game starts, even before the screen is initialized. If you require to load your assets, use Carbuncle::Game#load instead.
53 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 53 def before_run; end |
#file_dropped(*files) ⇒ nil
This method is called when a file is dropped.
71 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 71 def file_dropped(*files); end |
#load ⇒ nil
This method is called before the graphics context are created. Only really used when working on the web. This will prepare the files on the filesystem so the game can load them properly. Any file preloaded here will be awaited before starting the engine, on the loading screen. Any other initial configuration like screen size would be nice to be added here. If you don’t preload the file here, it will still be loaded, but may hang the website if the file is too big.
34 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 34 def load; end |
#on_resize(width, height) ⇒ nil
Called on the web when the canvas resizes
77 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 77 def on_resize(width, height); end |
#running? ⇒ Boolean
Returns true if a game is running
|
# File 'gems/carbuncle-core/mrblib/game.rb', line 4
|
#start ⇒ nil
This method is called after the graphics context is created and assets were prepared. This method is the one you run to setup the game.
46 |
# File 'gems/carbuncle-core/mrblib/game.rb', line 46 def start; end |