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

Class Poly

object --+    
         |    
     Shape --+
             |
            Poly

A convex polygon shape

Slowest, but most flexible collision shape.

Instance Methods
 
__init__(self, body, vertices, offset=(0, 0), auto_order_vertices=True)
Create a polygon
 
get_points(self)
Get the points in world coordinates for the polygon
 
__del__(self) (Inherited from pymunk.Shape)
 
cache_bb(self)
Update and returns the bouding box of this shape (Inherited from pymunk.Shape)
 
point_query(self, p)
Check if the given point lies within the shape. (Inherited from pymunk.Shape)
 
segment_query(self, start, end)
Check if the line segment from start to end intersects the shape. (Inherited from pymunk.Shape)

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

Static Methods
 
create_box(body, size=(10, 10))
Convenience function to create a box centered around the body position.
Properties
  body
The body this shape is attached to (Inherited from pymunk.Shape)
  collision_type
User defined collision type for the shape. See add_collisionpair_func function for more information on when to use this property (Inherited from pymunk.Shape)
  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. (Inherited from pymunk.Shape)
  friction
Friction coefficient. pymunk uses the Coulomb friction model, a value of 0.0 is frictionless. (Inherited from pymunk.Shape)
  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 (Inherited from pymunk.Shape)
  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 (Inherited from pymunk.Shape)
  sensor
A boolean value if this shape is a sensor or not. Sensors only call collision callbacks, and never generate real collisions. (Inherited from pymunk.Shape)
  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. (Inherited from pymunk.Shape)

Inherited from object: __class__

Method Details

__init__(self, body, vertices, offset=(0, 0), auto_order_vertices=True)
(Constructor)

 

Create a polygon

body : Body
The body to attach the poly to
vertices : [(x,y)] or [Vec2d]
Define a convex hull of the polygon with a counterclockwise winding.
offset : (x,y) or Vec2d
The offset from the body's center of gravity in body local coordinates.
auto_order_vertices : bool
Set to True to automatically order the vertices. If you know the vertices are in the correct (clockwise) orded you can gain a little performance by setting this to False.
Overrides: object.__init__

get_points(self)

 
Get the points in world coordinates for the polygon
Returns:
[Vec2d] in world coords