Class: Metro::UI::TileMap
- Defined in:
- lib/metro/models/ui/tile_map.rb
Overview
Draws a TileMap within the scene.
The viewport, or camera, of the TileMap is static but can be set to follow a particular actor within the scene. The viewport will continue to move according to the position of the specified actor.
Constant Summary
Constants included from Metro::Units
Instance Attribute Summary collapse
-
#file ⇒ Object
The Tiled File (*.tmx) that will be parsed and loaded for the tile map.
-
#follow ⇒ Object
The actor that the viewport of the scene will follow.
-
#rotation ⇒ Object
The rotation of each tile within the scene.
-
#viewport ⇒ Object
Set the viewport of the map, by default ths viewport will be the dimensions of the current Game, so this may not be necessary to set.
Attributes inherited from Model
Instance Method Summary collapse
- #draw ⇒ Object
-
#map ⇒ TMX::Map
The map object found in the specified TMX file.
-
#objects(params = nil) ⇒ Object
Find objects that match the specified type or by the specified parameters.
- #update ⇒ Object
Methods inherited from Model
#_load, #_save, #after_initialize, #bounds, #create, #draw_completed?, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #show, #to_hash, #update_completed?
Methods included from HasEvents
Methods included from KeyValueCoding
Methods included from PropertyOwner
Constructor Details
This class inherits a constructor from Metro::Model
Instance Attribute Details
#file ⇒ Object
The Tiled File (*.tmx) that will be parsed and loaded for the tile map
31 |
# File 'lib/metro/models/ui/tile_map.rb', line 31 property :file, type: :text |
#follow ⇒ Object
The actor that the viewport of the scene will follow.
35 |
# File 'lib/metro/models/ui/tile_map.rb', line 35 property :follow, type: :text |
#rotation ⇒ Object
The rotation of each tile within the scene. This is by default 0 and should likely remain 0.
40 |
# File 'lib/metro/models/ui/tile_map.rb', line 40 property :rotation |
Instance Method Details
#draw ⇒ Object
88 89 90 |
# File 'lib/metro/models/ui/tile_map.rb', line 88 def draw layers.each {|layer| layer.draw } end |
#map ⇒ TMX::Map
Returns the map object found in the specified TMX file.
60 61 62 63 64 65 66 |
# File 'lib/metro/models/ui/tile_map.rb', line 60 def map @map ||= begin map = ::Tmx.load asset_path(file) map.tilesets.each {|tileset| tileset.window = window } map end end |
#objects(params = nil) ⇒ Object
Find objects that match the specified type or by the specified parameters. If no parameter is provided then all the objects are returned
80 81 82 |
# File 'lib/metro/models/ui/tile_map.rb', line 80 def objects(params=nil) params ? map.objects.find(params) : map.objects end |
#update ⇒ Object
84 85 86 |
# File 'lib/metro/models/ui/tile_map.rb', line 84 def update end |