Package | org.cove.ape |
Class | public class SpringConstraint |
Inheritance | SpringConstraint ![]() ![]() |
Property | Defined by | ||
---|---|---|---|
![]() | alwaysRepaint : Boolean
For performance, fixed Particles and SpringConstraints don't have their
paint()
method called in order to avoid unnecessary redrawing. | AbstractItem | |
angle : Number [read-only]
The rotational value created by the positions of the two particles attached to this
SpringConstraint.
| SpringConstraint | ||
center : Vector
[read-only]
The center position created by the relative positions of the two particles attached to this
SpringConstraint.
| SpringConstraint | ||
collidable : Boolean [read-only]
Determines if the area between the two particles is tested for collision.
| SpringConstraint | ||
currLength : Number [read-only]
Returns the length of the SpringConstraint, the distance between its two
attached particles.
| SpringConstraint | ||
fixed : Boolean [read-only]
Returns true if both connected particle's
fixed property is true. | SpringConstraint | ||
fixedEndLimit : Number
For cases when the SpringConstraint is
collidable and only one of the
two end particles are fixed. | SpringConstraint | ||
radian : Number [read-only]
The rotational value created by the positions of the two particles attached to this
SpringConstraint.
| SpringConstraint | ||
rectHeight : Number
If the
collidable property is true, you can set the height of the
collidible rectangle between the two attached particles. | SpringConstraint | ||
rectScale : Number
If the
collidable property is true, you can set the scale of the collidible area
between the two attached particles. | SpringConstraint | ||
restLength : Number
The
restLength property sets the length of SpringConstraint. | SpringConstraint | ||
![]() | sprite : Sprite
Provides a Sprite to use as a container for drawing or adding children.
| AbstractItem | |
![]() | stiffness : Number
The stiffness of the constraint.
| AbstractConstraint | |
![]() | visible : Boolean
The visibility of the item.
| AbstractItem |
Method | Defined by | ||
---|---|---|---|
SpringConstraint(p1:AbstractParticle, p2:AbstractParticle, stiffness:Number = 0.5, collidable:Boolean = false, rectHeight:Number = 1, rectScale:Number = 1, scaleToLength:Boolean = false)
| SpringConstraint | ||
![]() |
cleanup():void
This method is called automatically when an item's parent group is removed
from the APEngine.
| AbstractItem | |
init():void
Sets up the visual representation of this SpringContraint.
| SpringConstraint | ||
isConnectedTo(p:AbstractParticle):Boolean
Returns true if the passed particle is one of the two particles attached to this SpringConstraint.
| SpringConstraint | ||
paint():void
The default painting method for this constraint.
| SpringConstraint | ||
setCollidable(b:Boolean, rectHeight:Number, rectScale:Number, scaleToLength:Boolean = false):void
| SpringConstraint | ||
setDisplay(d:DisplayObject, offsetX:Number = 0, offsetY:Number = 0, rotation:Number = 0):void
Assigns a DisplayObject to be used when painting this constraint.
| SpringConstraint | ||
![]() |
setFill(color:uint = 0xffffff, alpha:Number = 1):void
Sets the style of the fill for this Item.
| AbstractItem | |
![]() |
setLine(thickness:Number = 0, color:uint = 0x000000, alpha:Number = 1):void
Sets the style of the line for this Item.
| AbstractItem | |
![]() |
setStyle(lineThickness:Number = 0, lineColor:uint = 0x000000, lineAlpha:Number = 1, fillColor:uint = 0xffffff, fillAlpha:Number = 1):void
Sets the line and fill of this Item.
| AbstractItem |
angle | property |
angle:Number
[read-only]
The rotational value created by the positions of the two particles attached to this
SpringConstraint. You can use this property to in your own painting methods, along with the
center
property.
public function get angle():Number
center | property |
center:Vector
[read-only]The center position created by the relative positions of the two particles attached to this SpringConstraint. You can use this property to in your own painting methods, along with the rotation property.
Implementation public function get center():Vector
collidable | property |
collidable:Boolean
[read-only]
Determines if the area between the two particles is tested for collision. If this value is on
you can set the rectHeight
and rectScale
properties
to alter the dimensions of the collidable area.
public function get collidable():Boolean
currLength | property |
currLength:Number
[read-only]Returns the length of the SpringConstraint, the distance between its two attached particles.
Implementation public function get currLength():Number
fixed | property |
fixed:Boolean
[read-only]
Returns true if both connected particle's fixed
property is true.
public function get fixed():Boolean
fixedEndLimit | property |
fixedEndLimit:Number
[read-write]
For cases when the SpringConstraint is collidable
and only one of the
two end particles are fixed. This value will dispose of collisions near the
fixed particle, to correct for situations where the collision could never be
resolved. Values must be between 0.0 and 1.0.
public function get fixedEndLimit():Number
public function set fixedEndLimit(value:Number):void
radian | property |
radian:Number
[read-only]
The rotational value created by the positions of the two particles attached to this
SpringConstraint. You can use this property to in your own painting methods, along with the
center
property.
public function get radian():Number
rectHeight | property |
rectHeight:Number
[read-write]
If the collidable
property is true, you can set the height of the
collidible rectangle between the two attached particles. Valid values are greater
than 0. If you set the value to 10, then the collision rect will be 10 pixels high.
The height is perpendicular to the line connecting the two particles
public function get rectHeight():Number
public function set rectHeight(value:Number):void
rectScale | property |
rectScale:Number
[read-write]
If the collidable
property is true, you can set the scale of the collidible area
between the two attached particles. Valid values are from 0 to 1. If you set the value to 1, then
the collision area will extend all the way to the two attached particles. Setting the value lower
will result in an collision area that spans a percentage of that distance. Setting the value
higher will cause the collision rectangle to extend past the two end particles.
public function get rectScale():Number
public function set rectScale(value:Number):void
restLength | property |
restLength:Number
[read-write]
The restLength
property sets the length of SpringConstraint. This value will be
the distance between the two particles unless their position is altered by external forces.
The SpringConstraint will always try to keep the particles this distance apart. Values must
be > 0.
public function get restLength():Number
public function set restLength(value:Number):void
SpringConstraint | () | constructor |
public function SpringConstraint(p1:AbstractParticle, p2:AbstractParticle, stiffness:Number = 0.5, collidable:Boolean = false, rectHeight:Number = 1, rectScale:Number = 1, scaleToLength:Boolean = false)
Parameters
p1:AbstractParticle — The first particle this constraint is connected to.
|
|
p2:AbstractParticle — The second particle this constraint is connected to.
|
|
stiffness:Number (default = 0.5 ) — The strength of the spring. Valid values are between 0 and 1. Lower values
result in softer springs. Higher values result in stiffer, stronger springs.
|
|
collidable:Boolean (default = false ) — Determines if the constraint will be checked for collision
|
|
rectHeight:Number (default = 1 ) — If the constraint is collidable, the height of the collidable area
can be set in pixels. The height is perpendicular to the two attached particles.
|
|
rectScale:Number (default = 1 ) — If the constraint is collidable, the scale of the collidable area
can be set in value from 0 to 1. The scale is percentage of the distance between
the the two attached particles.
|
|
scaleToLength:Boolean (default = false ) — If the constraint is collidable and this value is true, the
collidable area will scale based on changes in the distance of the two particles.
|
init | () | method |
public override function init():void
Sets up the visual representation of this SpringContraint. This method is called automatically when an instance of this SpringContraint's parent Group is added to the APEngine, when this SpringContraint's Composite is added to a Group, or this SpringContraint is added to a Composite or Group.
isConnectedTo | () | method |
public function isConnectedTo(p:AbstractParticle):Boolean
Returns true if the passed particle is one of the two particles attached to this SpringConstraint.
Parametersp:AbstractParticle |
Boolean |
paint | () | method |
public override function paint():void
The default painting method for this constraint. This method is called automatically
by the APEngine.paint()
method. If you want to define your own custom painting
method, then create a subclass of this class and override paint()
.
setCollidable | () | method |
public function setCollidable(b:Boolean, rectHeight:Number, rectScale:Number, scaleToLength:Boolean = false):void
Parameters
b:Boolean |
|
rectHeight:Number |
|
rectScale:Number |
|
scaleToLength:Boolean (default = false )
|
setDisplay | () | method |
public function setDisplay(d:DisplayObject, offsetX:Number = 0, offsetY:Number = 0, rotation:Number = 0):void
Assigns a DisplayObject to be used when painting this constraint.
Parametersd:DisplayObject |
|
offsetX:Number (default = 0 )
|
|
offsetY:Number (default = 0 )
|
|
rotation:Number (default = 0 )
|