Top Level Namespace
Defined Under Namespace
Modules: Metro, Tmx Classes: BrandScene, BrandToTitleScene, Class, CustomEasing, FirstScene, GameScene, Hero, Numeric, TemplateMessage, TitleScene
Constant Summary collapse
- Game =
To allow an author an easier time accessing the Game object from within their game. They do not have to use the ‘Metro::Game` an instead use the `Game` constant.
Metro::Game
Instance Method Summary collapse
-
#asset_path(name) ⇒ Object
The asset_path is a helper which will generate a filepath based on the current working directory of the game.
-
#error!(messages, details = {}) ⇒ Object
Display an error message defined within the localization file.
-
#log ⇒ Object
Generates a default logger to standard out that can be used within Metro or the game.
-
#metro_asset_path(name) ⇒ Object
The metro_asset_path is a helper which will generate a filepath based on the directory of the metro library.
Instance Method Details
#asset_path(name) ⇒ Object
Paths that are defined within views use this helper and are assumed to be paths relative within the assets directory of the game. For images, samples, and songs in a model consider using a property.
Also consider the model classes Image, Animation, Song, and Sample for creating the assets found within the assets folder. Each of those will assist with using the asset_path internally to find the asset.
The asset_path is a helper which will generate a filepath based on the current working directory of the game. This allows for game author’s to specify a path relative within the assets directory of their game.
36 37 38 |
# File 'lib/metro/asset_path.rb', line 36 def asset_path(name) File.join Dir.pwd, "assets", name end |
#error!(messages, details = {}) ⇒ Object
Display an error message defined within the localization file. A game error displays a error title, message, and actions that can be taken to possibly address this issue.
25 26 27 28 29 30 31 32 33 |
# File 'lib/metro/logging.rb', line 25 def error!(, details = {}) details = { show: true, exit: true }.merge details = TemplateMessage.new messages: , details: details, website: Game.website, contact: Game.contact warn if details[:show] exit 1 if details[:exit] end |
#log ⇒ Object
Generates a default logger to standard out that can be used within Metro or the game.
9 10 11 12 13 14 15 |
# File 'lib/metro/logging.rb', line 9 def log @log ||= begin logger = Logger.new(STDOUT) logger.level = Logger::DEBUG logger end end |
#metro_asset_path(name) ⇒ Object
The metro_asset_path is a helper which will generate a filepath based on the directory of the metro library. This is used to retrieve internal assets which can be used to serve up missing images, animations, samples, or songs or defaults that may come with the metro game library.
47 48 49 |
# File 'lib/metro/asset_path.rb', line 47 def metro_asset_path(name) File.join Metro.asset_dir, name end |