class

CP::Shape

Inherits Reference / Object

Defines the shape of a rigid body.

Instance methods

area

Get the calculated area of this shape.

Source
bb

Get the bounding box that contains the shape given its current position and angle.

Only guaranteed to be valid after cache_bb or Space#step is called. Moving a body that a shape is connected to does not update its bounding box. For shapes used for queries that aren't attached to bodies, you can also use update.

Source
body

The Body this shape is added to.

Source
body=(body : Body | Nil)

Set the Body this shape is added to.

Can only be used if the shape is not currently added to a space.

Source
cache_bb

Update, cache and return the bounding box of a shape based on the body it's attached to.

Source
center_of_gravity

Get the centroid of this shape.

Source
collide(b : Shape) : ContactPointSet

Return contact information about two shapes.

Source
collision_type

User defined collision type for the shape.

See Space#add_collision_handler for more information.

Source
collision_type=(collision_type : Int)
Source
density

Get the density of the shape if you are having Chipmunk calculate mass properties for you.

Source
density=(density : Number)

Set the density of this shape to have Chipmunk calculate mass properties for you.

Source
elasticity

The elasticity of this shape.

A value of 0.0 gives no bounce, while a value of 1.0 will give a 'perfect' bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended.

Source
elasticity=(elasticity : Number)
Source
filter

The collision filtering parameters of this shape.

Source
filter=(filter : ShapeFilter)
Source
friction

The friction of this shape.

Chipmunk uses the Coulomb friction model, a value of 0.0 is frictionless. A value over 1.0 is also perfectly fine.

Source
friction=(friction : Number)
Source
mass

Get the mass of the shape if you are having Chipmunk calculate mass properties for you.

Source
mass=(mass : Number)

Set the mass of this shape to have Chipmunk calculate mass properties for you.

Source
moment

Get the calculated moment of inertia for this shape.

Source
point_query(p : Vect) : PointQueryInfo

Perform a nearest point query. It finds the closest point on the surface of shape to a specific point.

Source
segment_query(a : Vect, b : Vect, radius : Number = 0) : SegmentQueryInfo | Nil

Perform a segment query against a shape: check if the line segment from start to end intersects the shape.

Source
sensor=(sensor : Bool)
Source
sensor?

Is the shape set to be a sensor or not?

Sensors only call collision callbacks, and never generate real collisions.

Source
space

The Space this shape is added to.

Source
surface_velocity

The surface velocity of this shape.

Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.

Source
surface_velocity=(surface_velocity : Vect)
Source
update(transform : Transform) : BB

Update, cache and return the bounding box of a shape with an explicit transformation.

Useful if you have a shape without a body and want to use it for querying.

Source

Nested types