Mixin PhysicsBody

PhysicsBody mixin.

Apply to classes to give them physics body, along with relevant positional and rotational functions.

Usage:

    local MyClass = class("MyClass")
     MyClass:include( PhysicsBody )

Class PhysicsBody

PhysicsBody:getBody () Get the LÖVE physics body.
PhysicsBody:setPos (x, y) Set the body's position.
PhysicsBody:getPos () Gets the body's position.
PhysicsBody:move (x, y) Move this body relative to its current position.
PhysicsBody:setAngle (r) Set the body's angle.
PhysicsBody:getAngle () Gets the body's angle.
PhysicsBody:rotate (r) Rotate this body relatively to its current angle.
PhysicsBody:moveForward (d) Move this body forward (according to its current angle) by a given distance.
PhysicsBody:getDirection () Get the normal angle of the body's current angle.
PhysicsBody:onRemove () Called when the actor is removed.


Class PhysicsBody

PhysicsBody:getBody ()
Get the LÖVE physics body.

Returns:

    Body body
PhysicsBody:setPos (x, y)
Set the body's position.

Parameters:

  • x number x-coordinate.
  • y number y-coordinate.

Returns:

    PhysicsBody self
PhysicsBody:getPos ()
Gets the body's position.

Returns:

  1. number x
  2. number y
PhysicsBody:move (x, y)
Move this body relative to its current position.

Parameters:

  • x number relative x
  • y number relative y

Returns:

    PhysicsBody self
PhysicsBody:setAngle (r)
Set the body's angle.

Parameters:

  • r number angle (radians)

Returns:

    PhysicsBody self
PhysicsBody:getAngle ()
Gets the body's angle.

Returns:

    number r angle
PhysicsBody:rotate (r)
Rotate this body relatively to its current angle.

Parameters:

  • r number angle (radians)

Returns:

    PhysicsBody self
PhysicsBody:moveForward (d)
Move this body forward (according to its current angle) by a given distance.

Parameters:

  • d number distance

Returns:

    PhysicsBody self
PhysicsBody:getDirection ()
Get the normal angle of the body's current angle.

Returns:

    Vector normal vector
PhysicsBody:onRemove ()
Called when the actor is removed.
generated by LDoc 1.4.3 Last updated 2015-04-20 03:01:38