Package | com.fileitup.fisixengine.primitives |
Class | public class Magnet |
Implements | EngineObject |
A Magnet only affects objects within its parent FisixObject
A Magnet has no collision shape, and should probably be attached to an object
Property | Defined by | ||
---|---|---|---|
active : Boolean = true | Magnet | ||
force : Number | Magnet | ||
parent : FisixObject | Magnet | ||
recursive : Boolean = true | Magnet | ||
x : Number [read-only]
| Magnet | ||
y : Number [read-only]
| Magnet |
Method | Defined by | ||
---|---|---|---|
Creates a Magnet.
| Magnet | ||
attachToObject(obj:Particle):void
Attaches the Magent to a dynamic object.
| Magnet | ||
attachToVector(v:Vector):void
Attaches the Magnet to the given vector.
| Magnet | ||
dispose():void
Cleans the object so that it may be picked up by the garbage collector.
| Magnet | ||
render(g:Graphics):void
| Magnet | ||
setMagnetGroup(group:Array):void
Sets a group of objects to only be magnetized by the magnet.
| Magnet | ||
setPosition(x:Number, y:Number):void
This is the only way to manually set the position of the magnet.
| Magnet | ||
unload():void
Removes the Magnet from the FisixObject it belongs to, and disposes of it.
| Magnet |
active | property |
public var active:Boolean = true
force | property |
public var force:Number
parent | property |
public var parent:FisixObject
pos | property |
protected var pos:Vector
recursive | property |
public var recursive:Boolean = true
x | property |
x:Number
[read-only]Implementation
public function get x():Number
y | property |
y:Number
[read-only]Implementation
public function get y():Number
Magnet | () | constructor |
public function Magnet(cForce:Number, cPos:Vector, cParent:FisixObject = null)
Creates a Magnet.
ParameterscForce:Number — The force of the magnet. Positive attracts and negative repells.
|
|
cPos:Vector — A vector representing the global position of the object.
Use any Particle's 'pos' property as the argument to attach the magnet to that Object.
|
|
cParent:FisixObject (default = null ) — The parent of the magnet. You don't need to specify this if you'll be using FisixEngine.addMagnet().
|
attachToObject | () | method |
public function attachToObject(obj:Particle):void
Attaches the Magent to a dynamic object. This is the same as attaching it to the 'pos' property of the Particle through attachToVector()
Parametersobj:Particle |
See also
attachToVector | () | method |
public function attachToVector(v:Vector):void
Attaches the Magnet to the given vector. The magnet will be positioned where ever the vector is
Parametersv:Vector |
dispose | () | method |
public function dispose():void
Cleans the object so that it may be picked up by the garbage collector. To avoid errors, do not call this method before removing the object from the engine, or simply use unload()
See also
render | () | method |
public function render(g:Graphics):void
Parameters
g:Graphics |
setMagnetGroup | () | method |
public function setMagnetGroup(group:Array):void
Sets a group of objects to only be magnetized by the magnet. If a magnet group isn't set, all of the objects in the magnet's parent object will be magnetized.
Parametersgroup:Array — An array containing CollisionObjects. These may include Particles, Surfaces, and FisixObjects.
|
setPosition | () | method |
public function setPosition(x:Number, y:Number):void
This is the only way to manually set the position of the magnet. It also detaches it from any object/vector it may be attached to.
Parametersx:Number |
|
y:Number |
unload | () | method |
public function unload():void
Removes the Magnet from the FisixObject it belongs to, and disposes of it. This is the method that should be used when you are done with the Magnet.