Class: Physics

Carrot.Physics(game)

Carrot.Physics

Constructor

new Physics(game)

The Physics object offers physics related functions like collision detection.
Parameters:
Name Type Description
game Carrot.Game The core game object.
Source:

Classes

Body

Methods

collide(entity1, entity2, callbackopt) → {boolean}

Checks for collision between entities which can be sprites or groups.
Parameters:
Name Type Attributes Default Description
entity1 Carrot.Group | Carrot.Sprite
entity2 Carrot.Group | Carrot.Sprite
callback function <optional>
null The function that shall be executed when the collision happens.
Source:
Returns:
If a collision was detected.
Type
boolean

disable(entity)

Disables physics on a sprite by setting its body to null.
Parameters:
Name Type Description
entity Carrot.Sprite The sprite to get its physics disabled.
Source:

enable(entity)

Enables physics on a sprite by adding a physics body to it.
Parameters:
Name Type Description
entity Carrot.Sprite The sprite to get its physics enabled.
Source:

overlap(entity1, entity2, callbackopt) → {boolean}

Checks for overlaps between entities which can be sprites or groups.
Parameters:
Name Type Attributes Default Description
entity1 Carrot.Group | Carrot.Sprite
entity2 Carrot.Group | Carrot.Sprite
callback function <optional>
null The function that shall be executed when the overlap happens.
Source:
Returns:
If an overlap was detected.
Type
boolean

setCircle()

Changes the shape of the body and its parent sprite into a circle.
Source:

setRectangle()

Changes the shape of the body and its parent sprite into a rectangle.
Source: