Package | com.fileitup.fisixengine.constraints |
Class | public class SpringConstraint |
Inheritance | SpringConstraint ![]() |
Subclasses | StickConstraint |
The spring constraint is the most basic type of constraint, and is used to build both rigid and soft bodies. The StickConstraint is a derivative of the SpringConstraint who's stiffness value is always 1.
See also
Property | Defined by | ||
---|---|---|---|
![]() | breakPoint : Number The point at which a constraint should be broken.
| Constraint | |
![]() | broken : Boolean Tells you whether or not a constraint is currently broken.
| Constraint | |
max : Number [write-only]The upper range of the constraint.
| SpringConstraint | ||
min : Number [write-only]The lower range of the constraint.
| SpringConstraint | ||
![]() | parent : FisixObject | Constraint | |
particleA : Particle | SpringConstraint | ||
particleB : Particle | SpringConstraint | ||
restLength : Number The length that the constraint will attempt to maintain.
| SpringConstraint | ||
![]() | stiffness : Number A value between 0 - 1 representing the stiffness of the constraint.
| Constraint | |
![]() | unloadOnBreak : Boolean = true When true, the constraint is removed from the simulation when broken.
| Constraint |
Property | Defined by | ||
---|---|---|---|
restLengthSquared : Number | SpringConstraint | ||
restMinSquared : Number | SpringConstraint |
Method | Defined by | ||
---|---|---|---|
Creates a SpringConstraint object.
| SpringConstraint | ||
constraintAll(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining a list of objects to eachother.
| SpringConstraint | ||
constraintChain(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining a list of objects in a chain.
| SpringConstraint | ||
constraintTwoLists(fis:FisixObject, arrA:Array, arrB:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
[static]A static method for quickly constraining two lists of of objects to eachother.
| SpringConstraint | ||
dispose():void
| SpringConstraint | ||
getAngle():Number
| SpringConstraint | ||
render(g:Graphics):void
| SpringConstraint | ||
![]() |
setMinMax(minimum:Number, maximum:Number):void
Sets both min and max values in one line
| Constraint | |
solve():void
| SpringConstraint | ||
![]() |
unload():void
| Constraint |
Method | Defined by | ||
---|---|---|---|
![]() |
breakConstraint():void
| Constraint | |
![]() |
onBreak():void
| Constraint | |
![]() |
onUnload():void
| Constraint | |
solveConstraint(len:Number, len2:Number):void
| SpringConstraint |
max | property |
max:Number
[write-only]The upper range of the constraint.
By setting this value, you are disabling the use of the restLength property, so it's good practice to set both the min and max values at the same time.
Note that valid values are always positive values.
In order to disable the maximum bound, set this property to a negative value.
public function set max(value:Number):void
min | property |
min:Number
[write-only]The lower range of the constraint.
By setting this value, you are disabling the use of the restLength property, so it's good practice to set both the min and max values at the same time.
Note that valid values are always positive values.
In order to disable the minimum bound, set this property to a negative value.
public function set min(value:Number):void
particleA | property |
public var particleA:Particle
particleB | property |
public var particleB:Particle
restLength | property |
restLength:Number
[read-write]The length that the constraint will attempt to maintain.
For spring and stick constraints, this represents a pixel distance
For angular constraints, this represents a degree value between 0 and 360.
For more information about angle measures in angular constraints, see the documentation for the AngularConstraint class
Note that by setting this value you disable the use of min/max values (in other words, the constraint is no longer bound to a range, but only one value)
Implementation
public function get restLength():Number
public function set restLength(value:Number):void
restLengthSquared | property |
protected var restLengthSquared:Number
restMinSquared | property |
protected var restMinSquared:Number
SpringConstraint | () | constructor |
public function SpringConstraint(pA:Particle, pB:Particle, tStiff:Number = 0.5, rLen:Number = -1)
Creates a SpringConstraint object.
ParameterspA:Particle — the first object to constraint
|
|
pB:Particle — the second object to constraint
|
|
tStiff:Number (default = 0.5 ) — the stiffness of the constraint - a value between 0 and 1
|
|
rLen:Number (default = -1 ) — the rest length of the constraint. leave this at -1 to use the current distance between pA and pB
|
constraintAll | () | method |
public static function constraintAll(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
A static method for quickly constraining a list of objects to eachother.
Parametersfis:FisixObject — The FisixObject in which the constraints will be created.
|
|
arr:Array — An array of Particles to be constrained to eachother.
|
|
stiffness:Number (default = 0.5 ) — The stiffness of the created springs
|
|
breakPoint:Number (default = 0 ) — The breakPoint of the created springs. leave at 0 for unbreakable springs.
|
var box:FisixObject = new FisixObject() var p1:CircleParticle = box.newCircleParticle(0,0,20) var p2:CircleParticle = box.newCircleParticle(20,0,20) var p3:CircleParticle = box.newCircleParticle(20,20,20) var p4:CircleParticle = box.newCircleParticle(0,20,20) //you can constraint all these particles like so: SpringConstraint.constraintAll(box.particles) //or like so //SpringConstraint.constraintAll([p1,p2,p3,p4])
constraintChain | () | method |
public static function constraintChain(fis:FisixObject, arr:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
A static method for quickly constraining a list of objects in a chain. The first particle will be constrained to the second particle, which will be constrained to the third particle, and so on...
Parametersfis:FisixObject — The FisixObject in which the constraints will be created.
|
|
arr:Array — An array of Particles to be constrained into a chain.
|
|
stiffness:Number (default = 0.5 ) — The stiffness of the created springs
|
|
breakPoint:Number (default = 0 ) — The breakPoint of the created springs. leave at 0 for unbreakable springs.
|
var box:FisixObject = new FisixObject() var p1:CircleParticle = box.newCircleParticle(0,0,20) var p2:CircleParticle = box.newCircleParticle(20,0,20) var p3:CircleParticle = box.newCircleParticle(20,20,20) var p4:CircleParticle = box.newCircleParticle(0,20,20) //you can constraint all these particles like so: SpringConstraint.constraintChain(box.particles) //or like so //SpringConstraint.constraintChain([p1,p2,p3,p4])
constraintTwoLists | () | method |
public static function constraintTwoLists(fis:FisixObject, arrA:Array, arrB:Array, stiffness:Number = 0.5, breakPoint:Number = 0):void
A static method for quickly constraining two lists of of objects to eachother. All the objects in the first list will be constrained to all the objects in the second list.
Parametersfis:FisixObject — The FisixObject in which the constraints will be created.
|
|
arrA:Array — The first array of Particles to be constrained.
|
|
arrB:Array — The other array of Particles to be constrained.
|
|
stiffness:Number (default = 0.5 ) — The stiffness of the created springs
|
|
breakPoint:Number (default = 0 ) — The breakPoint of the created springs. leave at 0 for unbreakable springs.
|
var box:FisixObject = new FisixObject() var p1:CircleParticle = box.newCircleParticle(0,0,20) var p2:CircleParticle = box.newCircleParticle(20,0,20) var p3:CircleParticle = box.newCircleParticle(20,20,20) var p4:CircleParticle = box.newCircleParticle(0,20,20) SpringConstraint.constraintTwoLists([p1,p2],[p3,p4]) //note that p1 and p2 will be constrained to p3 and p4 //but p1 won't be constrained to p2, and neither will p3 be to p4
dispose | () | method |
public override function dispose():void
getAngle | () | method |
public function getAngle():Number
Returns
Number |
render | () | method |
public override function render(g:Graphics):void
Parameters
g:Graphics |
solve | () | method |
public override function solve():void
solveConstraint | () | method |
protected override function solveConstraint(len:Number, len2:Number):void
Parameters
len:Number |
|
len2:Number |