Class: RGSS::TMX::Map

Inherits:
MapObject show all
Defined in:
lib/rgss/tilemap.rb

Instance Attribute Summary collapse

Attributes inherited from MapObject

#properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MapObject

#parse_color

Constructor Details

#initialize(node) ⇒ Map

Returns a new instance of Map.


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rgss/tilemap.rb', line 49

def initialize(node)
  super(node)

  @version = node[:version]
  @orientation = node[:orientation].to_sym
  @render_order = node[:renderorder].sub('-', '').to_sym
  @width = node[:width].to_i
  @height = node[:height].to_i
  @tile_width = node[:tilewidth].to_i
  @tile_height = node[:tileheight].to_i
  @side_length = node[:hexsidelength].to_i
  @stagger_axis = node[:staggeraxis].to_i
  @infinite = !!node[:infinite]
  @back_color = parse_color(node[:backgroundcolor])

  @tilesets = node.locate('./tileset').map { |child| Tileset.new(child) }
  @layers = []
end

Instance Attribute Details

#back_colorObject (readonly)

Returns the value of attribute back_color


47
48
49
# File 'lib/rgss/tilemap.rb', line 47

def back_color
  @back_color
end

#heightObject (readonly)

Returns the value of attribute height


42
43
44
# File 'lib/rgss/tilemap.rb', line 42

def height
  @height
end

#orientationObject (readonly)

Returns the value of attribute orientation


39
40
41
# File 'lib/rgss/tilemap.rb', line 39

def orientation
  @orientation
end

#render_orderObject (readonly)

Returns the value of attribute render_order


40
41
42
# File 'lib/rgss/tilemap.rb', line 40

def render_order
  @render_order
end

#side_lengthObject (readonly)

Returns the value of attribute side_length


45
46
47
# File 'lib/rgss/tilemap.rb', line 45

def side_length
  @side_length
end

#stagger_axisObject (readonly)

Returns the value of attribute stagger_axis


46
47
48
# File 'lib/rgss/tilemap.rb', line 46

def stagger_axis
  @stagger_axis
end

#tile_widthObject (readonly)

Returns the value of attribute tile_width


43
44
45
# File 'lib/rgss/tilemap.rb', line 43

def tile_width
  @tile_width
end

#versionObject (readonly)

Returns the value of attribute version


38
39
40
# File 'lib/rgss/tilemap.rb', line 38

def version
  @version
end

#widthObject (readonly)

Returns the value of attribute width


41
42
43
# File 'lib/rgss/tilemap.rb', line 41

def width
  @width
end

Class Method Details

.load(path) ⇒ Object


31
32
33
34
35
36
# File 'lib/rgss/tilemap.rb', line 31

def self.load(path)
  opts = Ox.default_options
  opts[:symbolize_keys] = true
  doc = Ox.load_file(path, opts)
  new(doc.root)
end

.parse(xml) ⇒ Object


27
28
29
# File 'lib/rgss/tilemap.rb', line 27

def self.parse(xml)

end

Instance Method Details

#infinite?Boolean

Returns:

  • (Boolean)

68
69
70
# File 'lib/rgss/tilemap.rb', line 68

def infinite?
  @infinite
end

#pixel_heightObject


84
85
86
# File 'lib/rgss/tilemap.rb', line 84

def pixel_height
  @height * @tile_height
end

#pixel_widthObject


80
81
82
# File 'lib/rgss/tilemap.rb', line 80

def pixel_width
  @width * @tile_width
end

#sizeObject


72
73
74
# File 'lib/rgss/tilemap.rb', line 72

def size
  Size.new(@width, @height)
end

#tile_sizeObject


76
77
78
# File 'lib/rgss/tilemap.rb', line 76

def tile_size
  Size.new(@tile_width, @tile_height)
end