Class: Metro::UI::TileMapIsometricLayer

Inherits:
TileLayer show all
Defined in:
lib/metro/models/ui/tile_map.rb

Constant Summary

Constants included from Metro::Units

Metro::Units::Bounds

Instance Attribute Summary

Attributes inherited from TileLayer

#layer, #map, #tilesets, #viewport

Attributes inherited from Model

#scene, #window

Instance Method Summary collapse

Methods inherited from TileLayer

#build_tiles_index, #cached_images, #column, #data, #draw, #row, #tile_bounds, #tiles_within_viewport, #tileset_image, #x, #y, #z_order

Methods inherited from Model

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

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 Method Details

#half_tileheightObject



89
90
91
# File 'lib/metro/models/ui/tile_map.rb', line 89

def half_tileheight
  @half_tileheight ||= map.tileheight/2
end

#half_tilewidthObject



85
86
87
# File 'lib/metro/models/ui/tile_map.rb', line 85

def half_tilewidth
  @half_tilewidth ||= map.tilewidth/2
end

#position_of_image(image, row, column) ⇒ Object



111
112
113
114
115
# File 'lib/metro/models/ui/tile_map.rb', line 111

def position_of_image(image,row,column)
  pos_x = x_position(row,column) - (map.tilewidth - image.width)/2
  pos_y = y_position(row,column) + (map.tileheight - image.height)/2
  Bounds.new left: pos_x, top: pos_y, right: pos_x + map.tilewidth, bottom: pos_y + map.tileheight
end

#start_xObject



93
94
95
# File 'lib/metro/models/ui/tile_map.rb', line 93

def start_x
  @start_x ||= x + map.tilewidth * map.width / 2
end

#start_yObject



102
103
104
# File 'lib/metro/models/ui/tile_map.rb', line 102

def start_y
  y
end

#x_position(row, column) ⇒ Object



97
98
99
100
# File 'lib/metro/models/ui/tile_map.rb', line 97

def x_position(row,column)
  row_start_x = start_x - half_tilewidth * row
  row_start_x + half_tilewidth * column
end

#y_position(row, column) ⇒ Object



106
107
108
109
# File 'lib/metro/models/ui/tile_map.rb', line 106

def y_position(row,column)
  row_start_y = start_y + half_tileheight * row
  row_start_y + half_tileheight * column
end