API Docs for: 0.1.0
Show:

CG.Game Class

Extends Class
Module: CG

CG.Game - this class is the starting point for a cangaja game. The default object name of the instantiated object has to be 'Game'!


                        CG.Game.extend('MyGame', {
                           init: function (canvas, options) {
                               // call init from super class
                               this._super(canvas, options)
                               // add custom properties here or remove the init method
                           },
                           preload: function () {
                               // put preloading stuff here
                        
                               // for example
                               this.asset.addFont('media/font/small.txt', 'small', 'small')
                                   .addImage('media/img/player-anim.png', 'player-anim')
                                   .addJson('media/map/map1.json', 'map1')
                                   .startPreLoad()
                           },
                           create: function () {
                        
                               // put your create stuff here
                        
                               //after creation start game loop
                               this.loop()
                           },
                           update: function () {
                        
                               // additional update code not handled with in cangaja
                        
                           },
                           draw: function () {
                               // additional draw code not handled with in cangaja
                           }})
                        
                        // instantiate the Game class
                        Game = new CG.MyGame(canvas)
                        

Methods

afterDraw

()

this is the final draw method. it draws the b_canvas buffer to the canvas

beforeDraw

()

in this method all CG.Director elements are rendered to the canvas. after that the draw method is executed and some custom drawing is possible.

beforeUpdate

()

in this method all CG.Director elements are updated.

create

()

child classes that extends CG.Game could use this method to create all needed stuff.

draw

()

init

(
  • canvas
  • options
)

Parameters:

loop

()

this is the central (game) loop

preload

()

child classes that extends CG.Game defines here all needed stuff to preload with CG.MediaAsset.

update

()