Shape API Reference


A Shape object represents a 2D geometric shape that can be a) used to provide physical shapes that can be attached as fixtures to actors changing their shape in the physics system and b) used to provide a clipping shape to actors and scenes. Generally a Shape should be added to either a scene or the global app’s resources so that it can be managed by them.

A Shape can represent a convex shape or a concave shape. Concave shapes are represented by an array of convex shapes (convexVertices)

Public properties

  • name – The shapes name
  • parent – Parent container scene or app
  • type – Type of shape
  • width – Width of shape (or radius if circle)
  • height -Height of shape
  • vertices – Array of vertices for a polygon type shape in the form [x1,y1,x2,y2,....]
  • convexVertices – If shape is concave then contains an array of array of vertices that make up convex shapes, if empty then shape is convex and vertices should be used


  • b5.Shape.TypeBox – A box shape type
  • b5.Shape.TypeCircle – A circle shape type
  • b5.Shape.TypePolygon – A polygon shape type


Shape(name) – Creates an instance of a Shape object

  • The name of the geometry, this name is used when searching for resources in a Scene’s resources or the the app’s global resources

typeToConst(type_name) – Converts a string based shape type name to a Shape type constant

  • type – Name of the shape type (box, circle or polygon)

destroy() – Removes the shape from the scene / app and destroys it


Adding clipping to a scene

Adding a shape based fixture to an actor


1,152 total views, 1 views today