Packagecom.fileitup.fisixengine.primitives
Classpublic class Magnet
ImplementsEngineObject

A magnet for attracting and repelling objects.

A Magnet only affects objects within its parent FisixObject
A Magnet has no collision shape, and should probably be attached to an object



Public Properties
 PropertyDefined 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
Protected Properties
 PropertyDefined by
  pos : Vector
Magnet
Public Methods
 MethodDefined by
  
Magnet(cForce:Number, cPos:Vector, cParent:FisixObject = null)
Creates a Magnet.
Magnet
  
Attaches the Magent to a dynamic object.
Magnet
  
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
Property detail
activeproperty
public var active:Boolean = true
forceproperty 
public var force:Number
parentproperty 
public var parent:FisixObject
posproperty 
protected var pos:Vector
recursiveproperty 
public var recursive:Boolean = true
xproperty 
x:Number  [read-only]Implementation
    public function get x():Number
yproperty 
y:Number  [read-only]Implementation
    public function get y():Number
Constructor detail
Magnet()constructor
public function Magnet(cForce:Number, cPos:Vector, cParent:FisixObject = null)

Creates a Magnet.

Parameters
cForce: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().
Method detail
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()

Parameters
obj:Particle

See also

com.fileitup.fisixengine.core.Particle.pos
attachToVector()
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

Parameters
v: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):voidParameters
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.

Parameters
group: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.

Parameters
x: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.