Actors > Motion


Speed

Get Speed

x speed of actor

Returns the current [X / Y] speed for the actor.

[ACTOR].getXVelocity()
[ACTOR].getYVelocity()

Set Speed

set x speed to number for actor

Sets the [X / Y] speed for the actor.

[ACTOR].setXVelocity([NUMBER]);
[ACTOR].setYVelocity([NUMBER]);

Set Velocity (given Direction and Speed)

set velocity to dir number degrees , speed number for actor

Sets the actor's velocity, given a direction and a magnitude (speed) rather than X/Y components like above.

[ACTOR].setVelocity([NUMBER], [NUMBER]);

Force

Push (given X/Y)

push actor gently towards x dir number y dir number at number force

Pushes (or shoves) an actor, given an X/Y direction and force. Shoving is more "forceful" than pushing - experiment and see which works better for you.

[ACTOR].push([NUMBER], [NUMBER], [NUMBER]);
[ACTOR].applyImpulse([NUMBER], [NUMBER], [NUMBER]);

Push (given Angle)

push actor gently towards number degrees at number force

Pushes (or shoves) an actor, given an angle and force. Shoving is more "forceful" than pushing - experiment and see which works better for you.

[ACTOR].pushInDirection([NUMBER], [NUMBER]);
[ACTOR].applyImpulseInDirection([NUMBER], [NUMBER]);

Twist (rotate using force)

twist actor with number force

Twists (applies torque) to an actor, given a force.

[ACTOR].applyTorque(Utils.RAD * [NUMBER]);

Turning Speed

Get Turning Speed

turning speed of actor

Returns the turning speed (angular velocity) of the actor (in degrees).

Utils.DEG * ([ACTOR].getAngularVelocity())

Set Turning Speed

set turning speed to number for actor

Sets the turning speed (angular velocity) of the actor (in degrees). Positive turns clockwise. Negative turns counter-clockwise.

[ACTOR].setAngularVelocity(Utils.RAD * [NUMBER]);

Physics

Toggle Gravity

enable gravity for actor

Enables or disables gravity for this actor.

[ACTOR].setIgnoreGravity(false); //enable gravity
[ACTOR].setIgnoreGravity(true); //disable gravity

Toggle Rotation

enable rotation for actor

Enables or disableds rotation for this actor.

[ACTOR].enableRotation();
[ACTOR].disableRotation();

Set Friction / Bounciness

set friction to number for actor

Sets the actor's friction and bounciness settings. Provide a value between [0.0 - 1.0] inclusive.

Read our Physics guide for an explanation of what these fields mean.

[ACTOR].setFriction([NUMBER]);
[ACTOR].setBounciness([NUMBER]);
[ACTOR].setMass([NUMBER]);
[ACTOR].setAngularMass([NUMBER]);
[ACTOR].setLinearDamping([NUMBER]);
[ACTOR].setAngularDamping([NUMBER]);

Get Friction / Bounciness

friction of actor

Gets the actor's friction and bounciness settings. Read our Physics guide for an explanation of what these fields mean.

[ACTOR].getFriction()
[ACTOR].getBounciness()
[ACTOR].getMass()
[ACTOR].getAngularMass()
[ACTOR].getLinearDamping()
[ACTOR].getAngularDamping()