Body

Module: engine.physics

Physics body.

new game.Body([properties])

Parameters:

  • properties Object (optional)

Properties

_collides Array

(No description yet)

_collisionGroup Number

(No description yet)

collideAgainst Array (Default: [])

Group numbers that body collides against.

collisionGroup Number (Default: 0)

Collision group for body.

damping Number (Default: 0)

Body's damping. Should be number between 0 and 1.

force Vector (Default: 0,0)

Body's force.

last Vector

Body's position on last frame.

mass Number (Default: 1)

Body's mass.

position Vector

Position of body.

shape Rectangle|Circle

Body's shape.

static Boolean (Default: false)

Is body static.

velocity Vector

Body's velocity.

velocityLimit Vector (Default: 980,980)

Body's maximum velocity.

world World

Body's physic world.

Methods

_update()

(No description yet)

addShape(shape)

Add shape to body.

Parameters:

  • shape Rectangle|Circle
addTo(world)

Add body to world.

Parameters:

  • world World
afterCollide(body)

This is called after hit response.

Parameters:

  • body Body

    body that it collided with.

applyImpulse(x, [y])

Apply impulse to body.

Parameters:

  • x Number|Vector
  • y Number (optional)
collide(body, dir) Boolean

This is called, when body collides with another body.

Parameters:

  • body Body

    body that it collided with.

  • dir String

    direction of collision.

Return true, to apply hit response.

remove()

Remove body from it's world.

removeCollision()

Remove collision from body.