Class Index | File Index

Classes


Class cc.Director


Extends cc.Class.

Defined in: CCDirector.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

Class that creates and handle the main Window and manages how
and when to execute the Scenes.

Method Summary
Method Attributes Method Name and Description
 
 
calculates delta time since last time it was called
 
convertToGL(point)

converts a UIKit coordinate to an OpenGL coordinate
Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)

 
convertToUI(point)

converts an OpenGL coordinate to a UIKit coordinate
Useful to convert node points to window points for calls such as glScissor

 
ctor()
Constructor
 
Draw the scene.
 

Will enable Retina Display on devices that supports it.

 
end()
end director
 
 
 
Get the FPS value
 

get the size in pixels of the surface.

<static>  
cc.Director.getInstance()
returns a shared instance of the director
 
 
 

This object will be visited after the main scene is visited.

 
Get the CCEGLView, where everything is rendered
 
Sets an OpenGL projection
 
Get current running Scene.
 
(cc.Scheduler associated with this director)
 
seconds per frame
 
How many frames were called since the director started
 
 

returns the size of the OpenGL view in points.

 

returns the size of the OpenGL view in pixels.

 
 
init()
initializes cc.Director
 
Whether or not to display the FPS on the bottom-left corner
 
is next delta time zero
 
Whether or not the Director is paused
 

Whether or not the replaced scene will receive the cleanup message.

 
pause director
 

Pops out a scene from the queue.

 

Pops out all scenes from the queue until the root scene in the queue.

 
Removes cached all cocos2d cached data.
 
purge Director
 
pushScene(scene)

Suspends the execution of the running scene, pushing it on the stack of suspended scenes.

 
 
replaceScene(scene)
Replaces the running scene with a new one.
 
reshapeProjection(newWindowSize)
changes the projection size
 
resume director
 
runWithScene(scene)

Enters the Director's main loop with the given Scene.

 
setAccelerometer(accelerometer)
 
setActionManager(actionManager)
 
enables/disables OpenGL alpha blending
 
setContentScaleFactor(scaleFactor)

The size in pixels of the surface.

 
enables/disables OpenGL depth test
 
setDisplayStats(displayFPS)
Display the FPS on the bottom-left corner
 
sets the OpenGL default values
 
setKeyboardDispatcher(keyboardDispatcher)
 
setMouseDispatcher(mouseDispatcher)
 
setNextDeltaTimeZero(nextDeltaTimeZero)
set next delta time is zero
 
set next scene
 
set Notification Node
 
setOpenGLView(openGLView)
Set the CCEGLView, where everything is rendered
 
setProjection(projection)
Sets an OpenGL projection
 
setScheduler(scheduler)
 
setTouchDispatcher(touchDispatcher)
 
setWatcherCallbackFun(pSender, func)
 
update content scale factor
Class Detail
cc.Director()

Class that creates and handle the main Window and manages how
and when to execute the Scenes.

The cc.Director is also responsible for:
- initializing the OpenGL context
- setting the OpenGL pixel format (default on is RGB565)
- setting the OpenGL pixel format (default on is RGB565)
- setting the OpenGL buffer depth (default one is 0-bit)
- setting the projection (default one is 3D)
- setting the orientation (default one is Protrait)

Since the cc.Director is a singleton, the standard way to use it is by calling:
- cc.Director.getInstance().methodName();

The CCDirector also sets the default OpenGL context:
- GL_TEXTURE_2D is enabled
- GL_VERTEX_ARRAY is enabled
- GL_COLOR_ARRAY is enabled
- GL_TEXTURE_COORD_ARRAY is enabled

Method Detail
addRegionToDirtyRegion(rect)
Parameters:
rect

calculateDeltaTime()
calculates delta time since last time it was called

{cc.Point} convertToGL(point)

converts a UIKit coordinate to an OpenGL coordinate
Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)

Parameters:
{cc.Point} point
Returns:
{cc.Point}

{cc.Point} convertToUI(point)

converts an OpenGL coordinate to a UIKit coordinate
Useful to convert node points to window points for calls such as glScissor

Parameters:
{cc.Point} point
Returns:
{cc.Point}

ctor()
Constructor

drawScene()
Draw the scene. This method is called every frame. Don't call it manually.

{Boolean} enableRetinaDisplay(enabled)

Will enable Retina Display on devices that supports it.
It will enable Retina Display on iPhone4 and iPod Touch 4.
It will return YES, if it could enabled it, otherwise it will return NO.

This is the recommened way to enable Retina Display.

Parameters:
{Boolean} enabled
Returns:
{Boolean}

end()
end director

getAccelerometer()

getActionManager()

{Number} getAnimationInterval()
Get the FPS value
Returns:
{Number}

{Number} getContentScaleFactor()

get the size in pixels of the surface. It could be different than the screen size.
High-res devices might have a higher surface size than the screen size.
Only available when compiled using SDK >= 4.0.

Returns:
{Number}

<static> {cc.Director} cc.Director.getInstance()
returns a shared instance of the director
Returns:
{cc.Director}

getKeyboardDispatcher()

getMouseDispatcher()

{cc.Node} getNotificationNode()

This object will be visited after the main scene is visited.
This object MUST implement the "visit" selector.
Useful to hook a notification object, like CCNotifications (http://github.com/manucorporat/CCNotifications)

Returns:
{cc.Node}

{*} getOpenGLView()
Get the CCEGLView, where everything is rendered
Returns:
{*}

{Number} getProjection()
Sets an OpenGL projection
Returns:
{Number}

{cc.Scene} getRunningScene()
Get current running Scene. Director can only run one Scene at the time
Returns:
{cc.Scene}

getScheduler()
(cc.Scheduler associated with this director)

getSecondsPerFrame()
seconds per frame

{Number} getTotalFrames()
How many frames were called since the director started
Returns:
{Number}

getTouchDispatcher()

{cc.Size} getWinSize()

returns the size of the OpenGL view in points.
It takes into account any possible rotation (device orientation) of the window

Returns:
{cc.Size}

{cc.Size} getWinSizeInPixels()

returns the size of the OpenGL view in pixels.
It takes into account any possible rotation (device orientation) of the window.
On Mac winSize and winSizeInPixels return the same value.

Returns:
{cc.Size}

getZEye()

{Boolean} init()
initializes cc.Director
Returns:
{Boolean}

{Boolean} isDisplayStats()
Whether or not to display the FPS on the bottom-left corner
Returns:
{Boolean}

{Boolean} isNextDeltaTimeZero()
is next delta time zero
Returns:
{Boolean}

{Boolean} isPaused()
Whether or not the Director is paused
Returns:
{Boolean}

{Boolean} isSendCleanupToScene()

Whether or not the replaced scene will receive the cleanup message.
If the new scene is pushed, then the old scene won't receive the "cleanup" message.
If the new scene replaces the old one, the it will receive the "cleanup" message.

Returns:
{Boolean}

pause()
pause director

popScene()

Pops out a scene from the queue.
This scene will replace the running one.
The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
ONLY call it if there is a running scene.


popToRootScene()

Pops out all scenes from the queue until the root scene in the queue.
This scene will replace the running one.
The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
ONLY call it if there is a running scene.


purgeCachedData()
Removes cached all cocos2d cached data. It will purge the CCTextureCache, CCSpriteFrameCache, CCLabelBMFont cache

purgeDirector()
purge Director

pushScene(scene)

Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
The new scene will be executed.
Try to avoid big stacks of pushed scenes to reduce memory allocation.
ONLY call it if there is a running scene.

Parameters:
{cc.Scene} scene

rectIsInDirtyRegion(rect)
Parameters:
rect

replaceScene(scene)
Replaces the running scene with a new one. The running scene is terminated. ONLY call it if there is a running scene.
Parameters:
{cc.Scene} scene

reshapeProjection(newWindowSize)
changes the projection size
Parameters:
{cc.Size} newWindowSize

resume()
resume director

runWithScene(scene)

Enters the Director's main loop with the given Scene.
Call it to run only your FIRST scene.
Don't call it if there is already a running scene.

Parameters:
{cc.Scene} scene

setAccelerometer(accelerometer)
Parameters:
accelerometer

setActionManager(actionManager)
Parameters:
actionManager

setAlphaBlending(on)
enables/disables OpenGL alpha blending
Parameters:
{Boolean} on

setContentScaleFactor(scaleFactor)

The size in pixels of the surface. It could be different than the screen size.
High-res devices might have a higher surface size than the screen size.
Only available when compiled using SDK >= 4.0.

Parameters:
{Number} scaleFactor

setDepthTest(on)
enables/disables OpenGL depth test
Parameters:
{Boolean} on

setDisplayStats(displayFPS)
Display the FPS on the bottom-left corner
Parameters:
displayFPS

setGLDefaultValues()
sets the OpenGL default values

setKeyboardDispatcher(keyboardDispatcher)
Parameters:
keyboardDispatcher

setMouseDispatcher(mouseDispatcher)
Parameters:
mouseDispatcher

setNextDeltaTimeZero(nextDeltaTimeZero)
set next delta time is zero
Parameters:
{Boolean} nextDeltaTimeZero

setNextScene()
set next scene

setNotificationNode(node)
set Notification Node
Parameters:
{cc.Node} node

setOpenGLView(openGLView)
Set the CCEGLView, where everything is rendered
Parameters:
{*} openGLView

setProjection(projection)
Sets an OpenGL projection
Parameters:
{Number} projection

setScheduler(scheduler)
Parameters:
scheduler

setTouchDispatcher(touchDispatcher)
Parameters:
touchDispatcher

setWatcherCallbackFun(pSender, func)
Parameters:
pSender
func

updateContentScaleFactor()
update content scale factor

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:50 GMT-0800 (PST)