CG.Director Class
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))
Item Index
Properties
Methods
draw
()
getIndexOfScreen
(
False/Number
-
screenname
Parameters:
-
screenname
Stringto find index of screen in screen array
Returns:
False/Number:
return false or index number of the screen
getScreenByName
(
false/CG.Screen
-
screenname
Parameters:
-
screenname
Stringto find screen by name
Returns:
false/CG.Screen:
returns false or the screen object
init
()
Returns:
:
nextScreen
(
-
screenname
-
mode
-
duration
Parameters:
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);