Class: Metro::UI::TileMap

Inherits:
Model
  • Object
show all
Defined in:
lib/metro/models/ui/tile_map.rb

Constant Summary

Constants included from Metro::Units

Metro::Units::Bounds

Instance Attribute Summary collapse

Attributes inherited from Model

#scene, #window

Instance Method Summary collapse

Methods inherited from Model

#_load, #_save, #after_initialize, #bounds, #completed?, #create, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #to_hash

Methods included from HasEvents

included

Methods included from KeyValueCoding

#get, #set

Methods included from PropertyOwner

included, #properties

Constructor Details

This class inherits a constructor from Metro::Model

Instance Attribute Details

#layersObject

Returns the value of attribute layers.



125
126
127
# File 'lib/metro/models/ui/tile_map.rb', line 125

def layers
  @layers
end

#viewportObject

Returns the value of attribute viewport.



126
127
128
# File 'lib/metro/models/ui/tile_map.rb', line 126

def viewport
  @viewport
end

Instance Method Details

#drawObject



157
158
159
# File 'lib/metro/models/ui/tile_map.rb', line 157

def draw
  layers.each {|layer| layer.draw }
end

#layer_classObject



136
137
138
139
# File 'lib/metro/models/ui/tile_map.rb', line 136

def layer_class
  { orthogonal: "Metro::UI::TileMapOrthogonalLayer",
    isometric: "Metro::UI::TileMapIsometricLayer" }[map.orientation.to_sym].constantize
end

#mapObject



128
129
130
131
132
133
134
# File 'lib/metro/models/ui/tile_map.rb', line 128

def map
  @map ||= begin
    map = Tmxed.parse asset_path(file)
    map.tilesets.each {|tileset| tileset.window = window }
    map
  end
end

#showObject



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/metro/models/ui/tile_map.rb', line 141

def show
  self.layers = map.layers.collect do |layer|
    tml = layer_class.new
    tml.rotation = rotation
    tml.viewport = viewport
    tml.map = map
    tml.layer = layer
    tml.tilesets = map.tilesets
    tml
  end
end

#updateObject



153
154
155
# File 'lib/metro/models/ui/tile_map.rb', line 153

def update
  # update the layer with the current viewport position
end