CG.Font Class
CG.Font supports loading and drawing font files (EZ GUI Text format) from Glyph Designer, (Hiero works also but need some modifications of the exported files)
//create font object
small = new CG.Font().loadFont(Game.asset.getFontByName('small'))
//draw text to canvas
small.drawText('Foo bar!', xpos, ypos)
Item Index
Methods
Methods
AABB
()
Object
returns the bounds of rotated rectangle
Returns:
returns the calculated bounds
checkCollision
-
objects
-
callback
checks if there is a collision of the given objects to this object http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/
Parameters:
-
objects
Arraya array of objects to check for collision => Sprites, Animations, MapAreas
-
callback
Callbackwhat to do after collision?
draw
()
draw
-
text
-
xpos
-
ypos
draw the given text to the canvas
getTextWidth
-
text
get the width of the given text
Parameters:
-
text
Stringthe string to calculate the width
Returns:
textwidth
ifClicked
()
True/false
checks click inside of the rectangle, supports rotation
Returns:
ifMouseOver
()
checks if the mouse/pointer is over the rectangle
init
()
Returns:
loadFont
-
options
loadFont - load and parse the given fontfile
Parameters:
-
options
Object
Example:
gill = new CG.Font().loadFont({
font: this.asset.getFontByName('gill')
})
setImage
-
image
initialize image for object. for now => sprite, particle, buffer, bitmap and button use it
Parameters:
-
image
Imageimage path, image or atlasimage
update
()
Properties
atlas
Image
transform
Transform
Transform object for matrix transformation