Module: Metro::Tmx::TileLayer::IsometricPositioning

Defined in:
lib/metro/models/ui/tmx/isometric_position.rb

Instance Method Summary collapse

Instance Method Details

#half_tileheightObject



17
18
19
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 17

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

#half_tilewidthObject



13
14
15
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 13

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

#position_of_image(image, row, column) ⇒ Object



7
8
9
10
11
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 7

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
  ::Metro::Units::Bounds.new left: pos_x, top: pos_y, right: pos_x + map.tilewidth, bottom: pos_y + map.tileheight
end

#start_xObject



21
22
23
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 21

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

#start_yObject



30
31
32
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 30

def start_y
  y
end

#x_position(row, column) ⇒ Object



25
26
27
28
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 25

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



34
35
36
37
# File 'lib/metro/models/ui/tmx/isometric_position.rb', line 34

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