Class: Shape

b5. Shape


new b5.Shape(name){b5.Shape}

resource/shape.js, line 39

A Shape object represents a 2D geometric shape. A shape can be used to:

  • Provide physical shapes that can be attached as fixtures to b5.Actors changing their shape in the physics system
  • Provide visual shape to actors affecting how they are rendered
  • Provide clipping regions for b4.Scenes and {@link b5.Actor}s that support child clipping

Generally a shape should be added to either a b5.Scene or the global b5.App's resources so that it can be managed by them.

Example showing how to add a clipping shape to a scene

 var clipper = new b5.Shape();       // Create a circle shape
 clipper.type = b5.Shape.TypeCircle;
 clipper.width = 100;
 scene.clip_shape = clipper;      // Assign the shape as the scenes clip shape

For a complete overview of Resources see Booty5 Resources Overview

Name Type Description
name string

Name of shape resource

Name Type Description
parent b5.App | b5.Scene

Parent resource manager (internal)

name string

Name of this image atlas resource

type number

Type of shape

width number

Width of shape (or radius if circle)

height number

Height of shape

vertices Array.<number>

Array of vertices for a polygon type shape in the form [x1,y1,x2,y2,....]

convexVertices Array.<object>

If the shape represented by vertices is concave then this property contains a list of convex polygons, each element is an array of vertices

Type Description
b5.Shape The created shape



Shape is of type box


Shape is of type circle


Shape is of type polygon



resource/shape.js, line 88

Removes the shape from the scene / app and destroys it


resource/shape.js, line 74

Converts shape name to shape value

Name Type Description
type_name string

Name of shape

Type Description
number Shape type