Class: DXRuby::Tiled::Layer

Inherits:
Object
  • Object
show all
Defined in:
lib/dxruby_tiled/layer.rb

Direct Known Subclasses

GroupLayer, ImageLayer, ObjectGroup, TileLayer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, map) ⇒ Layer

Returns a new instance of Layer.



20
21
22
23
24
25
26
27
28
29
# File 'lib/dxruby_tiled/layer.rb', line 20

def initialize(data, map)
  @name       = data[:name]
  @opacity    = data[:opacity]    || 1.0
  @visible    = data[:visible] != false
  @offset_x   = data[:offsetx]    || 0
  @offset_y   = data[:offsety]    || 0
  @properties = data[:properties] || {}
  @z_index    = @properties[:z_index] || 0
  @fixed      = !!@properties[:fixed]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/dxruby_tiled/layer.rb', line 4

def name
  @name
end

#offset_xObject

Returns the value of attribute offset_x.



5
6
7
# File 'lib/dxruby_tiled/layer.rb', line 5

def offset_x
  @offset_x
end

#offset_yObject

Returns the value of attribute offset_y.



5
6
7
# File 'lib/dxruby_tiled/layer.rb', line 5

def offset_y
  @offset_y
end

#opacityObject

Returns the value of attribute opacity.



5
6
7
# File 'lib/dxruby_tiled/layer.rb', line 5

def opacity
  @opacity
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/dxruby_tiled/layer.rb', line 4

def properties
  @properties
end

#visibleObject

Returns the value of attribute visible.



5
6
7
# File 'lib/dxruby_tiled/layer.rb', line 5

def visible
  @visible
end

#z_indexObject

Returns the value of attribute z_index.



5
6
7
# File 'lib/dxruby_tiled/layer.rb', line 5

def z_index
  @z_index
end

Class Method Details

.create(data, map) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dxruby_tiled/layer.rb', line 7

def self.create(data, map)
  case data[:type]
  when "tilelayer"
    map.orientation.new(data, map)
  when "objectgroup"
    DXRuby::Tiled::ObjectGroup.new(data, map)
  when "imagelayer"
    DXRuby::Tiled::ImageLayer.new(data, map)
  when "group"
    DXRuby::Tiled::GroupLayer.new(data, map)
  end
end