Mixin Rotatable
Rotatable mixin.
Apply to classes that have a rotation.
Usage:
local MyClass = class("MyClass")
MyClass:include( Rotational )
Class Rotatable
| Rotatable:setAngle (r) | Set the object's angle. |
| Rotatable:getAngle () | Gets the object's angle. |
| Rotatable:rotate (r) | Rotate this object relatively to its current angle. |
| Rotatable:moveForward (d) | Move this object forward (according to its current angle) by a given distance. |
| Rotatable:getDirection () | Get the normal angle of the object's current angle. |
Class Rotatable
- Rotatable:setAngle (r)
-
Set the object's angle.
Parameters:
- r number angle (radians)
Returns:
-
Rotatable
self
- Rotatable:getAngle ()
-
Gets the object's angle.
Returns:
-
number
r angle
- Rotatable:rotate (r)
-
Rotate this object relatively to its current angle.
Parameters:
- r number angle (radians)
Returns:
-
Rotatable
self
- Rotatable:moveForward (d)
-
Move this object forward (according to its current angle) by a given distance.
Requires you to have a class:move( x, y ) function. For example, by including the Positional mixin.
Parameters:
- d number distance
Returns:
-
Rotatable
self
See also:
- Rotatable:getDirection ()
-
Get the normal angle of the object's current angle.
Returns:
-
Vector
normal vector