ForcesApi class

Available extensions

Constructors

ForcesApi(Movement comp)

Properties

comp → Movement
final
dragCoefficient → double
no setter
forcesEnabled → bool
no setter
friction → Vector2
no setter
gravity → Vector2
no setter
hashCode → int
The hash code for this object.
no setterinherited
isEnabled → bool
no setter
mass → double
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
wind → Vector2
no setter

Methods

addForce(String name, Vector2 force) → void
addImpulse(String name, Vector2 force, {double duration = 0.1}) → void

Available on ForcesApi, provided by the CommonForces extension

Add temporary impulse force (like explosion, jump, etc.)
addMagneticForce(String name, Vector2 target, double strength) → void

Available on ForcesApi, provided by the CommonForces extension

Add magnetic force towards a target
addOrbitalForce(String name, Vector2 center, double strength) → void

Available on ForcesApi, provided by the CommonForces extension

Add orbital force around a center point
addRepulsionForce(String name, Vector2 source, double strength, {double minDistance = 10}) → void

Available on ForcesApi, provided by the CommonForces extension

Add repulsion force from a point
addSpringForce(String name, Vector2 anchor, double stiffness, {double restLength = 0}) → void

Available on ForcesApi, provided by the CommonForces extension

Add spring force (like elastic band)
disable() → void
enable() → void
Enable/disable forces temporarily
enableEarthGravity() → void
Quick gravity setups
enableHighFriction() → void
enableIceFriction() → void
Quick friction setups
enableMoonGravity() → void
enableNormalFriction() → void
enableZeroGravity() → void
makeFlyingObject({Vector2? wind}) → void
makeGroundObject() → void
makeProjectile({Vector2? gravity}) → void
Quick physics presets for common scenarios
makeSpaceObject() → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeForce(String name) → void
setDragCoefficient(double coefficient) → void
Set air drag coefficient (0.0 to 1.0)
setFriction(Vector2 friction) → void
Set friction force (velocity reduction factor)
setGravity(Vector2 gravity) → void
Set gravity force (pixels/second²)
setMass(double mass) → void
Set mass of the object
setup({double? mass, double? dragCoefficient, bool? enabled, Vector2? gravity, Vector2? wind, Vector2? friction}) → void
setWind(Vector2 wind) → void
Set wind force (constant velocity addition)
toString() → String
A string representation of this object.
inherited
update(double dt) → void

Operators

operator ==(Object other) → bool
The equality operator.
inherited