new Object2D(name, pos, mass, drag, angularDrag, bounce, newtonianopt)
- Source:
Properties:
| Name |
Type |
Description |
id |
number
|
Internal ID |
name |
string
|
Object's name |
posOrigin |
Vector2
|
Original Positon |
scale |
Vector2
|
Scale |
rotation |
number
|
Rotation |
pivot |
Vector2
|
Rotation Pivot |
kinematic |
bool
|
Kinematic Object (not affected by physics) |
mass |
number
|
Mass |
newtonian |
bool
|
Newtonian Object (Orbits, atracts other bodies) |
drag |
number
|
Drag |
angularDrag |
number
|
Angular Drag |
bounce |
number
|
Coeficient of Restitution |
angularVelocity |
number
|
Angular Velocity |
lookAtTarget |
Object2D
|
Target look at |
lookAtOffset |
Vector2
|
Offset pivot on target look at |
velocity |
Vector2
|
Current Velocity |
force |
number
|
Force pending to apply |
color |
string
|
Color |
collisions |
number
|
Number of current collisions |
layer |
number
|
Layer |
parent |
Object2D
|
Parent Object. If set, the position is relative to the parent |
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
name |
string
|
|
|
Name |
pos |
Vector2
|
|
|
Start position |
mass |
number
|
|
|
Mass |
drag |
number
|
|
|
Drag |
angularDrag |
number
|
|
|
Angular Drag |
bounce |
number
|
|
|
Bounce factor |
newtonian |
bool
|
<optional>
|
false
|
Newtonian object (Atracts other bodys based on it's mass) |
Extends
Methods
addForce(force, forceTypeopt)
- Source:
Object2D.prototype.addForce - Applies a force to the Object2D
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
force |
Vector2
|
|
|
description |
forceType |
number
|
<optional>
|
0
|
The type of force: 0-Impulse, 1-Constant Force |
applyImpulse(impulse, contactVector)
- Source:
Object2D.prototype.applyImpulse - Applies an impulse
Parameters:
| Name |
Type |
Description |
impulse |
Vector2
|
The impulse |
contactVector |
Vector2
|
The point of the impulse |
setCollider(collider)
- Source:
Object2D.prototype.setCollider - Sets the collider
Parameters:
| Name |
Type |
Description |
collider |
Collider
|
The collider |
setInertia(value)
- Source:
Object2D.prototype.setInertia - Sets the inertia and the inverse inertia to the Object2D
Parameters:
| Name |
Type |
Description |
value |
number
|
The inertia |