Class: Gosu::Tiled::Layers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gosu_tiled/layers.rb

Instance Method Summary collapse

Constructor Details

#initialize(window, data, options) ⇒ Layers

Returns a new instance of Layers.



5
6
7
8
9
10
# File 'lib/gosu_tiled/layers.rb', line 5

def initialize(window, data, options)
  @window = window
  @layers = data.map do |layer|
    Layer.new(window, layer, options)
  end
end

Instance Method Details

#each(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/gosu_tiled/layers.rb', line 24

def each(&block)
  @layers.each do |layer|
    if block_given?
      block.call(layer)
    else
      yield layer
    end
  end
end

#objectObject



16
17
18
# File 'lib/gosu_tiled/layers.rb', line 16

def object
  @layers.select { |l| l.type == 'objectgroup' }.select(&:visible?)
end

#sizeObject



20
21
22
# File 'lib/gosu_tiled/layers.rb', line 20

def size
  @layers.size
end

#tileObject



12
13
14
# File 'lib/gosu_tiled/layers.rb', line 12

def tile
  @layers.select { |l| l.type == 'tilelayer' }.select(&:visible?)
end