Class: DXRuby::Tiled::TMEObject
- Inherits:
-
Sprite
- Object
- Sprite
- DXRuby::Tiled::TMEObject
- Defined in:
- lib/dxruby_tiled/object.rb
Direct Known Subclasses
EllipseObject, PointObject, PolygonObject, PolylineObject, RectangleObject, TextObject, TileObject
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(x, y, options = {}) ⇒ TMEObject
constructor
A new instance of TMEObject.
Constructor Details
#initialize(x, y, options = {}) ⇒ TMEObject
Returns a new instance of TMEObject.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dxruby_tiled/object.rb', line 39 def initialize(x, y, = {}) super x, y, nil @name = [:name] @type = [:type] @id = [:id] @width = [:width] @height = [:height] @properties = [:properties] self.angle = [:rotation] self.visible = [:visible] self.collision_sync = true end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/dxruby_tiled/object.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/dxruby_tiled/object.rb', line 5 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/dxruby_tiled/object.rb', line 4 def properties @properties end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/dxruby_tiled/object.rb', line 5 def type @type end |
Class Method Details
.create_from_hash(hash, map = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dxruby_tiled/object.rb', line 7 def self.create_from_hash(hash, map = nil) hash[:id] ||= map.next_object_id if hash[:template] template = map.load_template(hash[:template]) gid, source = template[:object][:gid], template[:tileset][:source] template[:object][:gid] = map.tilesets.gid_adjusted_by_source(gid, source) hash.merge!(template[:object]) end object = case when hash[:point] PointObject.create_from_hash(hash) when hash[:ellipse] EllipseObject.create_from_hash(hash) when hash[:polygon] PolygonObject.create_from_hash(hash) when hash[:polyline] PolylineObject.create_from_hash(hash) when hash[:text] TextObject.create_from_hash(hash) when hash[:gid] hash[:tile] = map.tilesets[hash[:gid]] TileObject.create_from_hash(hash) else RectangleObject.create_from_hash(hash) end if map && map.orientation == IsometricLayer object.extend(ObjectInIsometricMap) object.width_height = 1.0 * map.tile_height / map.tile_width end object end |