Class: Tmx::ObjectShape::CircularShape

Inherits:
Object
  • Object
show all
Includes:
ShapeDefaults
Defined in:
lib/tmx_ext/object_shape.rb

Instance Method Summary collapse

Methods included from ShapeDefaults

#default_elasticity, #default_sensor, #default_shape_attach_point

Instance Method Details

#match?(object) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/tmx_ext/object_shape.rb', line 56

def match?(object)
  object.contents['shape'] == 'ellipse'
  # raise "Only circular shapes are allowed to be specified" if (object.width / 2) != (object.height / 2)
end

#shape(object) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/tmx_ext/object_shape.rb', line 61

def shape(object)
  radius = object.width / 2
  offset = CP::Vec2.new(0,0)
  new_shape = CP::Shape::Circle.new(object.body, radius, offset)
  new_shape.collision_type = object.type.to_sym
  new_shape.e = default_elasticity
  new_shape.sensor = default_sensor
  new_shape
end