API Docs for: 0.1.0
Show:

CG.Director Class

Extends Class
Module: CG

CG.Director the top instance for CG.Screens, CG.Layers CG.B2DWorld, CG.Sprites and so on in the control hierarchy. Its main purpose is to collect CG.Screens under its hood and support some basic screen fading features.


                        //create top level CG.Director object
                        var director = new CG.Director()
                        
                        //create a CG.Screen
                        var mainscreen = new CG.Screen('mainscreen')
                        
                        //create a CG.Layer
                        var mainlayer = new CG.Layer('mainlayer')
                        
                        //create a demo CG.Sprite
                        var demosprite = new CG.Sprite(Game.asset.getImageByName('spritegfx'), new CG.Point(400, 240))
                        
                        //add/attach the demo sprite to the layer
                        mainlayer.addElement(back)
                        
                        //add/attach mainscreen and mainlayer to the director
                        director.addScreen(mainscreen.addLayer(mainlayer))
                        

Methods

addScreen

(
  • screen
)

Parameters:

draw

()

getActiveScreenName

() String

Returns:

String:

the name of the active screen

getIndexOfScreen

(
  • screenname
)
False/Number

Parameters:

  • screenname String

    to find index of screen in screen array

Returns:

False/Number:

return false or index number of the screen

getScreenByName

(
  • screenname
)
false/CG.Screen

Parameters:

  • screenname String

    to find screen by name

Returns:

false/CG.Screen:

returns false or the screen object

init

()

Returns:

:

nextScreen

(
  • screenname
  • mode
  • duration
)

Parameters:

  • screenname String

    to define nextscreen for fading

  • mode String

    mode for transition

  • duration Number

    the duration for fading

Example:

//tell the director class to fade to next screen with scale mode
                                            Game.director.nextScreen('gamescreen', 'scale', 10);
                                            
                                            //tell the director class to fade to next screen
                                            Game.director.nextScreen('settingsscreen', 'fade', 10);
                                            

update

()