addRectangle(layer,...properties) -> id , method of scene

Add a new Rectangle to this layer of the world.

Parameters:
name type description
layer int layer of the world (must be >= 0)
properties …Object each with Sprite properties for a Rectangle
Returns

the identifier (int) of the sprite

// a new blue Rectangle with its center at 200,300 and dimensions 40 and 60.

UB.scene.addRectangle(0, {x:200, y:300, width: 40, height: 60, fill: "#F00"});

Example with physical properties.

UB.scene.addRectangle(0, {
    x: 300,
    y: 300,
    width: 40,
    height: 50,
    fill: "#0F0"
}, {
    mass: 1,
    friction: 0.9,
    elasticity: 0.9
});

See all methods of the api.