The base class for all iio Objects (except Vec).

It defines an object with a position vector and translation methods. The rotation property is optional - it is only defined if you define it.

The properties and functions of Obj are available to all iio Objects (except Vec).

This class must be accessed through the iio package.



These functions are used to instantiate new instances of the Obj class. Constructor functions must be preceded by the new keyword.


iio.Obj( Vector position )

- Creates an object with the given position vector. The default position is 0,0.

var pos = new iio.Vec(1, 1);            
var obj = new iio.Obj(pos);

iio.Obj( Number x, Number y )

- creates an object at the coordinates (x, y). The default position is 0,0.

var obj = new iio.Obj(1, 1);


The data contained in each Obj instance.


.pos :: Vec

- An vector representing the object's position.

var obj = new iio.Obj(1,1);
//get obj position
var position = obj.pos; //position will be an Vec
var xPos = obj.pos.x;
var yPos = obj.pos.y;

.rotation :: Number

- This objects rotation. This property is UNDEFINED by DEFAULT, you must use the rotate() function or set a value directly if you want a rotation that is not equivalent to 'undefined'.

var obj = new iio.Obj(1,1);
var r = obj.rotation //r will be undefined

//set obj rotation
obj.rotation = 90;

//get obj rotation
var r2 = obj.rotation; //r will be 90


These functions are available to all Obj instances.



:: Returns Obj

- Creates and returns a new Obj object with the same properties as this object. Makes a hard copy of the object.

var obj = new iio.Obj();
//copy the obj
var obj2 = obj; //WRONG: this is a soft copy
                //the variables will point to the same object
obj2 = obj.clone(); //RIGHT: this is a hard copy

.setPos( Vec pos )

.setPos( Number x, Number y )

:: Returns this

- Sets the position of the object to the given coordinates or vector.

var obj = new iio.Obj(1,1);
//set obj position
var pos = new iio.Vec(10,10);
//obj.pos will now have the coordinates (10,10)

.translate( Vec v )

.translate( Number x, Number y )

:: Returns this

- moves the object by adding the given coordinates or vector to its position.

var obj = new iio.Obj(1,1);
//translate obj
var pos = new iio.Vec(10,10);
//obj.pos will have the coordinates (11, 11) after one translation

.rotate( Number radians)

:: Returns this

- sets the rotation of this object to the given value. This radian chart is helpful.

var obj = new iio.Obj();
//rotate the obj 90 degrees

.enableUpdates( Function callback, Array callbackParams )

:: Returns this

- adds an update function, allowing automated movement and effects. This function can be called multiple times to apply additional update callbacks.

- note that kinematics and effects functions call this function automatically.