class DXRuby::Tiled::TMEObject
Attributes
id[R]
name[RW]
properties[R]
type[RW]
Public Class Methods
create_from_hash(hash, map = nil)
click to toggle source
# 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
new(x, y, options = {})
click to toggle source
Calls superclass method
# File lib/dxruby_tiled/object.rb, line 39 def initialize(x, y, options = {}) super x, y, nil @name = options[:name] @type = options[:type] @id = options[:id] @width = options[:width] @height = options[:height] @properties = options[:properties] self.angle = options[:rotation] self.visible = options[:visible] self.collision_sync = true end