Class: Bestguigui::Tiled::ObjectLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/bestguigui/tiled.rb

Overview

Couche d'objets (spawns, zones, marqueurs...) — les propriétés custom définies dans Tiled sont sur chaque Object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ObjectLayer

Returns a new instance of ObjectLayer.



116
117
118
119
# File 'lib/bestguigui/tiled.rb', line 116

def initialize(data)
  @name = data["name"]
  @objects = (data["objects"] || []).map { |object_data| Object.new(object_data) }
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



114
115
116
# File 'lib/bestguigui/tiled.rb', line 114

def name
  @name
end

#objectsObject (readonly)

Returns the value of attribute objects.



114
115
116
# File 'lib/bestguigui/tiled.rb', line 114

def objects
  @objects
end

Instance Method Details

#objects_of_type(type) ⇒ Object



121
122
123
# File 'lib/bestguigui/tiled.rb', line 121

def objects_of_type(type)
  @objects.select { |object| object.type == type }
end