Package pymunk :: Class Shape
[frames] | no frames]

Class Shape

object --+
         |
        Shape
Known Subclasses:

Base class for all the shapes.

You usually dont want to create instances of this class directly but use one of the specialized shapes instead.

Instance Methods
 
__init__(self, shape=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__del__(self)
 
cache_bb(self)
Update and returns the bouding box of this shape
 
point_query(self, p)
Check if the given point lies within the shape.
 
segment_query(self, start, end)
Check if the line segment from start to end intersects the shape.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  sensor
A boolean value if this shape is a sensor or not.
  collision_type
User defined collision type for the shape.
  group
Shapes in the same non-zero group do not generate collisions.
  layers
Shapes only collide if they are in the same bit-planes.
  elasticity
Elasticity of the shape.
  friction
Friction coefficient.
  surface_velocity
The surface velocity of the object.
  body
The body this shape is attached to

Inherited from object: __class__

Method Details

__init__(self, shape=None)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

segment_query(self, start, end)

 

Check if the line segment from start to end intersects the shape.

Return either SegmentQueryInfo object or None


Property Details

sensor

A boolean value if this shape is a sensor or not. Sensors only call collision callbacks, and never generate real collisions.
Get Method:
_get_sensor(self)
Set Method:
_set_sensor(self, is_sensor)

collision_type

User defined collision type for the shape. See add_collisionpair_func function for more information on when to use this property
Get Method:
_get_collision_type(self)
Set Method:
_set_collision_type(self, t)

group

Shapes in the same non-zero group do not generate collisions. Useful when creating an object out of many shapes that you don't want to self collide. Defaults to 0
Get Method:
_get_group(self)
Set Method:
_set_group(self, group)

layers

Shapes only collide if they are in the same bit-planes. i.e. (a.layers & b.layers) != 0. By default, a shape occupies all 32 bit-planes, i.e. layers == -1
Get Method:
_get_layers(self)
Set Method:
_set_layers(self, layers)

elasticity

Elasticity of the 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.
Get Method:
_get_elasticity(self)
Set Method:
_set_elasticity(self, e)

friction

Friction coefficient. pymunk uses the Coulomb friction model, a value of 0.0 is frictionless.
Get Method:
_get_friction(self)
Set Method:
_set_friction(self, u)

surface_velocity

The surface velocity of the object. Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not resolving the collision.
Get Method:
_get_surface_velocity(self)
Set Method:
_set_surface_velocity(self, surface_v)

body

The body this shape is attached to
Get Method:
unreachable(self)