API Docs for: 0.1.0
Show:

CG.Font Class

Extends CG.Entity
Module: CG

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)
                        

Methods

AABB

() Object

returns the bounds of rotated rectangle

Returns:

Object:

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 Array

    a array of objects to check for collision => Sprites, Animations, MapAreas

  • callback Callback

    what to do after collision?

draw

()

draw

(
  • text
  • xpos
  • ypos
)

draw the given text to the canvas

Parameters:

getFontSize

() Number

get the font size of the current font

Returns:

Number:

size font size

getLineHeight

() Number

get the line height of the current font

Returns:

Number:

lineheight

getTextWidth

(
  • text
)
Number

get the width of the given text

Parameters:

  • text String

    the string to calculate the width

Returns:

Number:

textwidth

ifClicked

() True/false

checks click inside of the rectangle, supports rotation

Returns:

True/false:

ifMouseOver

()

checks if the mouse/pointer is over the rectangle

init

()

Inherited from CG.Entity but overwritten in cangaja/text/font.js:22

Returns:

:

loadFont

(
  • options
)

loadFont - load and parse the given fontfile

Parameters:

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 Image

    image path, image or atlasimage

update

()

Properties

atlas

Image

boundingradius

Number

chars

Array

clicked

Boolean

currentX

Number

currentY

Number

dragable

Boolean

height

Array

Inherited from CG.Entity but overwritten in cangaja/text/font.js:56

initText

String

italic

Number

lineHeight

Number

mapcollision

Boolean

rotation

Number

scaleH

Number

scaleW

Number

transform

Transform

Transform object for matrix transformation

visible

Boolean

visibility option

width

Array

Inherited from CG.Entity but overwritten in cangaja/text/font.js:52

xadv

Array

xhandle

Number

xoff

Array

xscale

Number

yhandle

Number

yoff

Array

yscale

Number