XShape

Extends :: SimpleRect :: Shape :: Obj

Essentially, all this class does is provide a class so that the Graphics Engine can override SimpleRect's draw function to draw an x-shape instead of a rectangle.

Therefore, although this class inherits all the shape and image graphics properties, none of them can be used.

Think of this class as extending a line when it comes to rendering.

Kinematics are still available though.

This class must be accessed through the iio package.

 

Constructors

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

 

iio.XShape( Vector position, Number: width, height )

iio.XShape( Number x, y, width, height )

- creates a x-shape with the given position and dimensions. If the height is omitted, a square x-shape will be created with the width as its size.

- The default value for all parameters is 0.

//create a 60x60 x-shape at canvas center
var squareX = new iio.XShape(io.canvas.center,60);

//create a 40x60 x-shape at 0,0
var x = new iio.XShape(0,0,40,60);
 

Inherited Properties

XShape :: SimpleRect :: Shape :: Obj

Obj.pos :: ioVec

Obj.rotation :: Number

SimpleRect.width :: Number

SimpleRect.height :: Number

 

Graphics Properties

The following properties can are attached by the iio Graphics Engine. Note that these properties are 'undefined' by default, so you must define them with their set functions or set their values directly.

.styles.alpha :: Number

.styles.strokeStyle :: Color||Pattern||Gradient

.styles.lineWidth :: Number

.styles.shadow :: Object

.styles.fxFade :: Object

.styles.fillStyle :: Color||Pattern||Gradient

.img :: Image

.anims :: Array

.animKey :: Number

.animFrame :: Number

 

Kinematics Properties

The following properties can are attached by the iio Kinematics Engine. Note that these properties are 'undefined' by default, so you must define them with their set functions or set their values directly.

.vel :: Vec

.acc :: Vec

.torque :: Number

.shrinkRate :: Number

.bounds :: Object

 

Inherited Functions

XShape :: SimpleRect :: Shape :: Obj

Obj.setPos

Obj.translate

Obj.rotate

SimpleRect.setSize

SimpleRect.contains

SimpleRect.intersectsWith

SimpleRect.top

SimpleRect.right

SimpleRect.bottom

SimpleRect.right

 

Kinematics Functions

The following functions can are attached by the iio Kinematics Engine. Note that you must call the enableKinematics function before you can utilize any of these functions.

 

Functions

These functions are added by the XShape class, and available to all instantiated XShape objects.

 

.clone()

:: Returns XShape

- returns a new XShape with the same properties as this one. Makes a hard copy of the object.

//clone an x-shape
var x2 = x.clone();