Class cc.Director

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

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

  • calculateDeltaTime()
    calculates delta time since last time it was called
  • {cc.Point} convertToGL(uiPoint)

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

    Parameters:
    {cc.Point} uiPoint
    Returns:
    {cc.Point}
  • {cc.Point} convertToUI(glPoint)

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

    Parameters:
    {cc.Point} glPoint
    Returns:
    {cc.Point}
  • ctor()
    Constructor
  • drawScene()
    Draw the scene. This method is called every frame. Don't call it manually.
  • end()
    end director
  • {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}
  • {cc.DirectorDelegate} getDelegate()
    CCDirector delegate. It shall implemente the CCDirectorDelegate protocol
    Returns:
    {cc.DirectorDelegate}
  • <static> {cc.Director} cc.Director.getInstance()
    returns a shared instance of the director
    Returns:
    {cc.Director}
  • {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)
  • {Number} getSecondsPerFrame()
    seconds per frame
    Returns:
    {Number}
  • {Number} getTotalFrames()
    How many frames were called since the director started
    Returns:
    {Number}
  • {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}
  • {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.
    Internally it will call `popToSceneStackLevel(1)`

  • popToSceneStackLevel(level)

    Pops out all scenes from the queue until it reaches `level`.
    If level is 0, it will end the director.
    If level is 1, it will pop all scenes until it reaches to root scene.
    If level is <= than the current stack level, it won't do anything.

    Parameters:
    {Number} level
  • 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
  • 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
  • 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
  • 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
  • setDefaultValues()
    sets the default values based on the CCConfiguration info
  • setDepthTest(on)
    enables/disables OpenGL depth test
    Parameters:
    {Boolean} on
  • setDisplayStats(displayStats)
    Display the FPS on the bottom-left corner
    Parameters:
    {Boolean} displayStats
  • setGLDefaultValues()
    sets the OpenGL default values
  • 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
  • setViewport()
    Sets the glViewport