Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Director Class Reference

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

Inherits Ref.

Inherited by DisplayLinkDirector.

Public Types

enum  Projection { _2D, _3D, CUSTOM, DEFAULT = _3D }
 Possible OpenGL projections used by director. More...
 

Public Member Functions

ScenegetRunningScene ()
 Gets current running Scene. More...
 
var getRunningScene ()
 Gets current running Scene. More...
 
local getRunningScene ()
 Gets current running Scene. More...
 
float getAnimationInterval ()
 Gets the FPS value. More...
 
void setAnimationInterval (float interval)
 Sets the FPS value. More...
 
var setAnimationInterval ( var interval)
 Sets the FPS value. More...
 
local setAnimationInterval ( local interval)
 Sets the FPS value. More...
 
bool isDisplayStats ()
 Whether or not displaying the FPS on the bottom-left corner of the screen. More...
 
void setDisplayStats (bool displayStats)
 Display the FPS on the bottom-left corner of the screen. More...
 
var setDisplayStats ( var displayStats)
 Display the FPS on the bottom-left corner of the screen. More...
 
local setDisplayStats ( local displayStats)
 Display the FPS on the bottom-left corner of the screen. More...
 
float getSecondsPerFrame ()
 Get seconds per frame. More...
 
var getSecondsPerFrame ()
 Get seconds per frame. More...
 
local getSecondsPerFrame ()
 Get seconds per frame. More...
 
GLViewgetOpenGLView ()
 Get the GLView.
 
void setOpenGLView (GLView *openGLView)
 Sets the GLView.
 
var setOpenGLView ( var openGLView)
 Sets the GLView.
 
bool isNextDeltaTimeZero ()
 Whether or not _nextDeltaTimeZero is set to 0. More...
 
var isNextDeltaTimeZero ()
 Whether or not _nextDeltaTimeZero is set to 0. More...
 
local isNextDeltaTimeZero ()
 Whether or not _nextDeltaTimeZero is set to 0. More...
 
void setNextDeltaTimeZero (bool nextDeltaTimeZero)
 Sets the delta time between current frame and next frame is 0. More...
 
bool isPaused ()
 Whether or not the Director is paused. More...
 
unsigned int getTotalFrames ()
 How many frames were called since the director started.
 
var getTotalFrames ()
 How many frames were called since the director started.
 
local getTotalFrames ()
 How many frames were called since the director started.
 
Projection getProjection ()
 Gets an OpenGL projection. More...
 
var getProjection ()
 Gets an OpenGL projection. More...
 
void setProjection (Projection projection)
 Sets OpenGL projection. More...
 
void setViewport ()
 Sets the glViewport. More...
 
var setViewport ()
 Sets the glViewport. More...
 
local setViewport ()
 Sets the glViewport. More...
 
bool isSendCleanupToScene ()
 Whether or not the replaced scene will receive the cleanup message. More...
 
NodegetNotificationNode () const
 This object will be visited after the main scene is visited. More...
 
void setNotificationNode (Node *node)
 Sets the notification node. More...
 
var setNotificationNode ( var node)
 Sets the notification node. More...
 
local setNotificationNode ( local node)
 Sets the notification node. More...
 
const Size & getWinSize () const
 Returns the size of the OpenGL view in points. More...
 
var getWinSize ()
 Returns the size of the OpenGL view in points. More...
 
local getWinSize ()
 Returns the size of the OpenGL view in points. More...
 
Size getWinSizeInPixels () const
 Returns the size of the OpenGL view in pixels. More...
 
var getWinSizeInPixels ()
 Returns the size of the OpenGL view in pixels. More...
 
local getWinSizeInPixels ()
 Returns the size of the OpenGL view in pixels. More...
 
Size getVisibleSize () const
 Returns visible size of the OpenGL view in points. More...
 
Vec2 getVisibleOrigin () const
 Returns visible origin coordinate of the OpenGL view in points. More...
 
var getVisibleOrigin ()
 Returns visible origin coordinate of the OpenGL view in points. More...
 
local getVisibleOrigin ()
 Returns visible origin coordinate of the OpenGL view in points. More...
 
Rect getSafeAreaRect () const
 Returns safe area rectangle of the OpenGL view in points.
 
var getSafeAreaRect ()
 Returns safe area rectangle of the OpenGL view in points.
 
local getSafeAreaRect ()
 Returns safe area rectangle of the OpenGL view in points.
 
Vec2 convertToGL (const Vec2 &point)
 Converts a screen coordinate to an OpenGL coordinate. More...
 
local convertToGL ( local point)
 Converts a screen coordinate to an OpenGL coordinate. More...
 
Vec2 convertToUI (const Vec2 &point)
 Converts an OpenGL coordinate to a screen coordinate. More...
 
float getZEye () const
 Gets the distance between camera and near clipping frame. More...
 
var getZEye ()
 Gets the distance between camera and near clipping frame. More...
 
local getZEye ()
 Gets the distance between camera and near clipping frame. More...
 
void runWithScene (Scene *scene)
 Enters the Director's main loop with the given Scene. More...
 
local runWithScene ( local scene)
 Enters the Director's main loop with the given Scene. More...
 
void pushScene (Scene *scene)
 Suspends the execution of the running scene, pushing it on the stack of suspended scenes. More...
 
void popScene ()
 Pops out a scene from the stack. More...
 
void popToRootScene ()
 Pops out all scenes from the stack until the root scene in the queue. More...
 
void popToSceneStackLevel (int level)
 Pops out all scenes from the stack until it reaches level. More...
 
var popToSceneStackLevel ( var level)
 Pops out all scenes from the stack until it reaches level. More...
 
local popToSceneStackLevel ( local level)
 Pops out all scenes from the stack until it reaches level. More...
 
void replaceScene (Scene *scene)
 Replaces the running scene with a new one. More...
 
void end ()
 Ends the execution, releases the running scene.
 
void pause ()
 Pauses the running scene. More...
 
local pause ()
 Pauses the running scene. More...
 
void resume ()
 Resumes the paused scene. More...
 
var resume ()
 Resumes the paused scene. More...
 
local resume ()
 Resumes the paused scene. More...
 
void stopAnimation ()
 Stops the animation. More...
 
void startAnimation ()
 The main loop is triggered again. More...
 
void drawScene ()
 Draw the scene. More...
 
var drawScene ()
 Draw the scene. More...
 
local drawScene ()
 Draw the scene. More...
 
void purgeCachedData ()
 Removes all cocos2d cached data. More...
 
local purgeCachedData ()
 Removes all cocos2d cached data. More...
 
void setDefaultValues ()
 Sets the default values based on the Configuration info. More...
 
local setDefaultValues ()
 Sets the default values based on the Configuration info. More...
 
void setGLDefaultValues ()
 Sets the OpenGL default values. More...
 
void setAlphaBlending (bool on)
 Enables/disables OpenGL alpha blending. More...
 
void setClearColor (const Color4F &clearColor)
 Sets clear values for the color buffers, value range of each element is [0.0, 1.0].
 
local setClearColor ( local clearColor)
 Sets clear values for the color buffers, value range of each element is [0.0, 1.0].
 
void setDepthTest (bool on)
 Enables/disables OpenGL depth test. More...
 
void mainLoop (float dt)
 Invoke main loop with delta time. More...
 
var mainLoop ( var dt)
 Invoke main loop with delta time. More...
 
local mainLoop ( local dt)
 Invoke main loop with delta time. More...
 
void setContentScaleFactor (float scaleFactor)
 The size in pixels of the surface. More...
 
float getContentScaleFactor () const
 Gets content scale factor. More...
 
SchedulergetScheduler () const
 Gets the Scheduler associated with this director. More...
 
var getScheduler ()
 Gets the Scheduler associated with this director. More...
 
local getScheduler ()
 Gets the Scheduler associated with this director. More...
 
void setScheduler (Scheduler *scheduler)
 Sets the Scheduler associated with this director. More...
 
var setScheduler ( var scheduler)
 Sets the Scheduler associated with this director. More...
 
local setScheduler ( local scheduler)
 Sets the Scheduler associated with this director. More...
 
ActionManagergetActionManager () const
 Gets the ActionManager associated with this director. More...
 
var getActionManager ()
 Gets the ActionManager associated with this director. More...
 
local getActionManager ()
 Gets the ActionManager associated with this director. More...
 
void setActionManager (ActionManager *actionManager)
 Sets the ActionManager associated with this director. More...
 
var setActionManager ( var actionManager)
 Sets the ActionManager associated with this director. More...
 
local setActionManager ( local actionManager)
 Sets the ActionManager associated with this director. More...
 
EventDispatchergetEventDispatcher () const
 Gets the EventDispatcher associated with this director. More...
 
local getEventDispatcher ()
 Gets the EventDispatcher associated with this director. More...
 
void setEventDispatcher (EventDispatcher *dispatcher)
 Sets the EventDispatcher associated with this director. More...
 
local setEventDispatcher ( local dispatcher)
 Sets the EventDispatcher associated with this director. More...
 
Renderer * getRenderer () const
 Returns the Renderer associated with this director. More...
 
var getRenderer ()
 Returns the Renderer associated with this director. More...
 
local getRenderer ()
 Returns the Renderer associated with this director. More...
 
Console * getConsole () const
 Returns the Console associated with this director. More...
 
local getConsole ()
 Returns the Console associated with this director. More...
 
float getFrameRate () const
 Gets Frame Rate.
 
local getFrameRate ()
 Gets Frame Rate.
 
void pushMatrix (MATRIX_STACK_TYPE type)
 Clones a specified type matrix and put it to the top of specified type of matrix stack.
 
local pushMatrix ( local type)
 Clones a specified type matrix and put it to the top of specified type of matrix stack.
 
void pushProjectionMatrix (size_t index)
 Clones a projection matrix and put it to the top of projection matrix stack. More...
 
void popMatrix (MATRIX_STACK_TYPE type)
 Pops the top matrix of the specified type of matrix stack.
 
local popMatrix ( local type)
 Pops the top matrix of the specified type of matrix stack.
 
void popProjectionMatrix (size_t index)
 Pops the top matrix of the projection matrix stack. More...
 
local popProjectionMatrix ( local index)
 Pops the top matrix of the projection matrix stack. More...
 
void loadIdentityMatrix (MATRIX_STACK_TYPE type)
 Adds an identity matrix to the top of specified type of matrix stack.
 
void loadProjectionIdentityMatrix (size_t index)
 Adds an identity matrix to the top of projection matrix stack. More...
 
local loadProjectionIdentityMatrix ( local index)
 Adds an identity matrix to the top of projection matrix stack. More...
 
void loadMatrix (MATRIX_STACK_TYPE type, const Mat4 &mat)
 Adds a matrix to the top of specified type of matrix stack. More...
 
local loadMatrix ( local type, local mat)
 Adds a matrix to the top of specified type of matrix stack. More...
 
void loadProjectionMatrix (const Mat4 &mat, size_t index)
 Adds a matrix to the top of projection matrix stack. More...
 
void multiplyMatrix (MATRIX_STACK_TYPE type, const Mat4 &mat)
 Multiplies a matrix to the top of specified type of matrix stack. More...
 
void multiplyProjectionMatrix (const Mat4 &mat, size_t index)
 Multiplies a matrix to the top of projection matrix stack. More...
 
const Mat4getMatrix (MATRIX_STACK_TYPE type) const
 Gets the top matrix of specified type of matrix stack.
 
const Mat4getProjectionMatrix (size_t index) const
 Gets the top matrix of projection matrix stack. More...
 
void resetMatrixStack ()
 Clear all types of matrix stack, and add identity matrix to these matrix stacks.
 
void initProjectionMatrixStack (size_t stackCount)
 Init the projection matrix stack. More...
 
local initProjectionMatrixStack ( local stackCount)
 Init the projection matrix stack. More...
 
size_t getProjectionMatrixStackSize ()
 Get the size of projection matrix stack.
 
const std::thread::id & getCocos2dThreadId () const
 returns the cocos2d thread id. More...
 
local getCocos2dThreadId ()
 returns the cocos2d thread id. More...
 
bool isValid () const
 returns whether or not the Director is in a valid state
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
local release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Static Public Member Functions

static DirectorgetInstance ()
 Returns a shared instance of the director.
 
var _getInstance ()
 Returns a shared instance of the director.
 
local getInstance ()
 Returns a shared instance of the director.
 
static DirectorsharedDirector ()

Static Public Attributes

static const char * EVENT_BEFORE_SET_NEXT_SCENE
 Director will trigger an event before set next scene. More...
 
var EVENT_BEFORE_SET_NEXT_SCENE
 Director will trigger an event before set next scene. More...
 
local EVENT_BEFORE_SET_NEXT_SCENE
 Director will trigger an event before set next scene. More...
 
static const char * EVENT_AFTER_SET_NEXT_SCENE
 Director will trigger an event after set next scene. More...
 
static const char * EVENT_PROJECTION_CHANGED
 Director will trigger an event when projection type is changed. More...
 
var EVENT_PROJECTION_CHANGED
 Director will trigger an event when projection type is changed. More...
 
local EVENT_PROJECTION_CHANGED
 Director will trigger an event when projection type is changed. More...
 
static const char * EVENT_BEFORE_UPDATE
 Director will trigger an event before Schedule::update() is invoked. More...
 
var EVENT_BEFORE_UPDATE
 Director will trigger an event before Schedule::update() is invoked. More...
 
local EVENT_BEFORE_UPDATE
 Director will trigger an event before Schedule::update() is invoked. More...
 
static const char * EVENT_AFTER_UPDATE
 Director will trigger an event after Schedule::update() is invoked. More...
 
var EVENT_AFTER_UPDATE
 Director will trigger an event after Schedule::update() is invoked. More...
 
local EVENT_AFTER_UPDATE
 Director will trigger an event after Schedule::update() is invoked. More...
 
static const char * EVENT_RESET
 Director will trigger an event while resetting Director.
 
static const char * EVENT_AFTER_VISIT
 Director will trigger an event after Scene::render() is invoked. More...
 
var EVENT_AFTER_VISIT
 Director will trigger an event after Scene::render() is invoked. More...
 
local EVENT_AFTER_VISIT
 Director will trigger an event after Scene::render() is invoked. More...
 
static const char * EVENT_AFTER_DRAW
 Director will trigger an event after a scene is drawn, the data is sent to GPU. More...
 
var EVENT_AFTER_DRAW
 Director will trigger an event after a scene is drawn, the data is sent to GPU. More...
 
local EVENT_AFTER_DRAW
 Director will trigger an event after a scene is drawn, the data is sent to GPU. More...
 
static const char * EVENT_BEFORE_DRAW
 Director will trigger an event before a scene is drawn, right after clear. More...
 
var EVENT_BEFORE_DRAW
 Director will trigger an event before a scene is drawn, right after clear. More...
 
local EVENT_BEFORE_DRAW
 Director will trigger an event before a scene is drawn, right after clear. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

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

The Director is also responsible for:

  • initializing the OpenGL context
  • setting the OpenGL buffer depth (default one is 0-bit)
  • setting the projection (default one is 3D)

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

Member Function Documentation

static Director* sharedDirector ( )
inlinestatic
local sharedDirector ( )
inlinestatic
Scene* getRunningScene ( )
inline

Gets current running Scene.

Director can only run one Scene at a time.

var getRunningScene ( )
inline

Gets current running Scene.

Director can only run one Scene at a time.

local getRunningScene ( )
inline

Gets current running Scene.

Director can only run one Scene at a time.

float getAnimationInterval ( )
inline

Gets the FPS value.

var getAnimationInterval ( )
inline

Gets the FPS value.

local getAnimationInterval ( )
inline

Gets the FPS value.

void setAnimationInterval ( float  interval)

Sets the FPS value.

FPS = 1/interval.

var setAnimationInterval ( var  interval)

Sets the FPS value.

FPS = 1/interval.

local setAnimationInterval ( local  interval)

Sets the FPS value.

FPS = 1/interval.

bool isDisplayStats ( )
inline

Whether or not displaying the FPS on the bottom-left corner of the screen.

var isDisplayStats ( )
inline

Whether or not displaying the FPS on the bottom-left corner of the screen.

local isDisplayStats ( )
inline

Whether or not displaying the FPS on the bottom-left corner of the screen.

void setDisplayStats ( bool  displayStats)
inline

Display the FPS on the bottom-left corner of the screen.

var setDisplayStats ( var  displayStats)
inline

Display the FPS on the bottom-left corner of the screen.

local setDisplayStats ( local  displayStats)
inline

Display the FPS on the bottom-left corner of the screen.

float getSecondsPerFrame ( )
inline

Get seconds per frame.

var getSecondsPerFrame ( )
inline

Get seconds per frame.

local getSecondsPerFrame ( )
inline

Get seconds per frame.

bool isNextDeltaTimeZero ( )
inline

Whether or not _nextDeltaTimeZero is set to 0.

var isNextDeltaTimeZero ( )
inline

Whether or not _nextDeltaTimeZero is set to 0.

local isNextDeltaTimeZero ( )
inline

Whether or not _nextDeltaTimeZero is set to 0.

void setNextDeltaTimeZero ( bool  nextDeltaTimeZero)

Sets the delta time between current frame and next frame is 0.

This value will be used in Schedule, and will affect all functions that are using frame delta time, such as Actions. This value will take effect only one time.

var setNextDeltaTimeZero ( var  nextDeltaTimeZero)

Sets the delta time between current frame and next frame is 0.

This value will be used in Schedule, and will affect all functions that are using frame delta time, such as Actions. This value will take effect only one time.

local setNextDeltaTimeZero ( local  nextDeltaTimeZero)

Sets the delta time between current frame and next frame is 0.

This value will be used in Schedule, and will affect all functions that are using frame delta time, such as Actions. This value will take effect only one time.

bool isPaused ( )
inline

Whether or not the Director is paused.

var isPaused ( )
inline

Whether or not the Director is paused.

local isPaused ( )
inline

Whether or not the Director is paused.

Projection getProjection ( )
inline

Gets an OpenGL projection.

Since
v0.8.2
var getProjection ( )
inline

Gets an OpenGL projection.

Since
v0.8.2
void setProjection ( Projection  projection)

Sets OpenGL projection.

var setProjection ( var  projection)

Sets OpenGL projection.

local setProjection ( local  projection)

Sets OpenGL projection.

void setViewport ( )

Sets the glViewport.

var setViewport ( )

Sets the glViewport.

local setViewport ( )

Sets the glViewport.

bool isSendCleanupToScene ( )
inline

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.

Since
v0.99.0
var isSendCleanupToScene ( )
inline

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.

Since
v0.99.0
local isSendCleanupToScene ( )
inline

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.

Since
v0.99.0
Node* getNotificationNode ( ) const
inline

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

This object MUST implement the "visit" function. Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)

Since
v0.99.5
var getNotificationNode ( )
inline

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

This object MUST implement the "visit" function. Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)

Since
v0.99.5
local getNotificationNode ( )
inline

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

This object MUST implement the "visit" function. Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)

Since
v0.99.5
void setNotificationNode ( Node node)

Sets the notification node.

See also
Director::getNotificationNode()
var setNotificationNode ( var  node)

Sets the notification node.

See also
Director::getNotificationNode()
local setNotificationNode ( local  node)

Sets the notification node.

See also
Director::getNotificationNode()
const Size& getWinSize ( ) const

Returns the size of the OpenGL view in points.

var getWinSize ( )

Returns the size of the OpenGL view in points.

local getWinSize ( )

Returns the size of the OpenGL view in points.

Size getWinSizeInPixels ( ) const

Returns the size of the OpenGL view in pixels.

var getWinSizeInPixels ( )

Returns the size of the OpenGL view in pixels.

local getWinSizeInPixels ( )

Returns the size of the OpenGL view in pixels.

Size getVisibleSize ( ) const

Returns visible size of the OpenGL view in points.

The value is equal to Director::getWinSize() if don't invoke GLView::setDesignResolutionSize().

var getVisibleSize ( )

Returns visible size of the OpenGL view in points.

The value is equal to Director::getWinSize() if don't invoke GLView::setDesignResolutionSize().

local getVisibleSize ( )

Returns visible size of the OpenGL view in points.

The value is equal to Director::getWinSize() if don't invoke GLView::setDesignResolutionSize().

Vec2 getVisibleOrigin ( ) const

Returns visible origin coordinate of the OpenGL view in points.

var getVisibleOrigin ( )

Returns visible origin coordinate of the OpenGL view in points.

local getVisibleOrigin ( )

Returns visible origin coordinate of the OpenGL view in points.

Vec2 convertToGL ( const Vec2 point)

Converts a screen coordinate to an OpenGL coordinate.

Useful to convert (multi) touch coordinates to the current layout (portrait or landscape).

var convertToGL ( var  point)

Converts a screen coordinate to an OpenGL coordinate.

Useful to convert (multi) touch coordinates to the current layout (portrait or landscape).

local convertToGL ( local  point)

Converts a screen coordinate to an OpenGL coordinate.

Useful to convert (multi) touch coordinates to the current layout (portrait or landscape).

Vec2 convertToUI ( const Vec2 point)

Converts an OpenGL coordinate to a screen coordinate.

Useful to convert node points to window points for calls such as glScissor.

var convertToUI ( var  point)

Converts an OpenGL coordinate to a screen coordinate.

Useful to convert node points to window points for calls such as glScissor.

local convertToUI ( local  point)

Converts an OpenGL coordinate to a screen coordinate.

Useful to convert node points to window points for calls such as glScissor.

float getZEye ( ) const

Gets the distance between camera and near clipping frame.

It is correct for default camera that near clipping frame is same as the screen.

var getZEye ( )

Gets the distance between camera and near clipping frame.

It is correct for default camera that near clipping frame is same as the screen.

local getZEye ( )

Gets the distance between camera and near clipping frame.

It is correct for default camera that near clipping frame is same as the screen.

void runWithScene ( Scene 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.

It will call pushScene: and then it will call startAnimation

local runWithScene ( local  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.

It will call pushScene: and then it will call startAnimation

void pushScene ( Scene 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.

var pushScene ( var  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.

local pushScene ( local  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.

void popScene ( )

Pops out a scene from the stack.

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.

var popScene ( )

Pops out a scene from the stack.

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.

local popScene ( )

Pops out a scene from the stack.

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.

void popToRootScene ( )

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

This scene will replace the running one. Internally it will call popToSceneStackLevel(1).

var popToRootScene ( )

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

This scene will replace the running one. Internally it will call popToSceneStackLevel(1).

local popToRootScene ( )

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

This scene will replace the running one. Internally it will call popToSceneStackLevel(1).

void popToSceneStackLevel ( int  level)

Pops out all scenes from the stack 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.

var popToSceneStackLevel ( var  level)

Pops out all scenes from the stack 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.

local popToSceneStackLevel ( local  level)

Pops out all scenes from the stack 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.

void replaceScene ( Scene scene)

Replaces the running scene with a new one.

The running scene is terminated. ONLY call it if there is a running scene.

local replaceScene ( local  scene)

Replaces the running scene with a new one.

The running scene is terminated. ONLY call it if there is a running scene.

void pause ( )

Pauses the running scene.

The running scene will be drawed but all scheduled timers will be paused. While paused, the draw rate will be 4 FPS to reduce CPU consumption.

var pause ( )

Pauses the running scene.

The running scene will be drawed but all scheduled timers will be paused. While paused, the draw rate will be 4 FPS to reduce CPU consumption.

local pause ( )

Pauses the running scene.

The running scene will be drawed but all scheduled timers will be paused. While paused, the draw rate will be 4 FPS to reduce CPU consumption.

void resume ( )

Resumes the paused scene.

The scheduled timers will be activated again. The "delta time" will be 0 (as if the game wasn't paused).

var resume ( )

Resumes the paused scene.

The scheduled timers will be activated again. The "delta time" will be 0 (as if the game wasn't paused).

local resume ( )

Resumes the paused scene.

The scheduled timers will be activated again. The "delta time" will be 0 (as if the game wasn't paused).

void stopAnimation ( )

Stops the animation.

Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead.

var stopAnimation ( )

Stops the animation.

Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead.

local stopAnimation ( )

Stops the animation.

Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead.

void startAnimation ( )

The main loop is triggered again.

Call this function only if [stopAnimation] was called earlier.

Warning
Don't call this function to start the main loop. To run the main loop call runWithScene.
var startAnimation ( )

The main loop is triggered again.

Call this function only if [stopAnimation] was called earlier.

Warning
Don't call this function to start the main loop. To run the main loop call runWithScene.
local startAnimation ( )

The main loop is triggered again.

Call this function only if [stopAnimation] was called earlier.

Warning
Don't call this function to start the main loop. To run the main loop call runWithScene.
void drawScene ( )

Draw the scene.

This method is called every frame. Don't call it manually.

var drawScene ( )

Draw the scene.

This method is called every frame. Don't call it manually.

local drawScene ( )

Draw the scene.

This method is called every frame. Don't call it manually.

void purgeCachedData ( )

Removes all cocos2d cached data.

It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache

Since
v0.99.3
var purgeCachedData ( )

Removes all cocos2d cached data.

It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache

Since
v0.99.3
local purgeCachedData ( )

Removes all cocos2d cached data.

It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache

Since
v0.99.3
void setDefaultValues ( )

Sets the default values based on the Configuration info.

var setDefaultValues ( )

Sets the default values based on the Configuration info.

local setDefaultValues ( )

Sets the default values based on the Configuration info.

void setGLDefaultValues ( )

Sets the OpenGL default values.

It will enable alpha blending, disable depth test.

local setGLDefaultValues ( )

Sets the OpenGL default values.

It will enable alpha blending, disable depth test.

void setAlphaBlending ( bool  on)

Enables/disables OpenGL alpha blending.

var setAlphaBlending ( var  on)

Enables/disables OpenGL alpha blending.

local setAlphaBlending ( local  on)

Enables/disables OpenGL alpha blending.

void setDepthTest ( bool  on)

Enables/disables OpenGL depth test.

var setDepthTest ( var  on)

Enables/disables OpenGL depth test.

local setDepthTest ( local  on)

Enables/disables OpenGL depth test.

void mainLoop ( float  dt)

Invoke main loop with delta time.

Then calculateDeltaTime can just use the delta time directly. The delta time paseed may include vsync time. See issue #17806

Since
3.16
var mainLoop ( var  dt)

Invoke main loop with delta time.

Then calculateDeltaTime can just use the delta time directly. The delta time paseed may include vsync time. See issue #17806

Since
3.16
local mainLoop ( local  dt)

Invoke main loop with delta time.

Then calculateDeltaTime can just use the delta time directly. The delta time paseed may include vsync time. See issue #17806

Since
3.16
void setContentScaleFactor ( float  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.

Since
v0.99.4
var setContentScaleFactor ( var  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.

Since
v0.99.4
local setContentScaleFactor ( local  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.

Since
v0.99.4
float getContentScaleFactor ( ) const
inline

Gets content scale factor.

See also
Director::setContentScaleFactor()
var getContentScaleFactor ( )
inline

Gets content scale factor.

See also
Director::setContentScaleFactor()
local getContentScaleFactor ( )
inline

Gets content scale factor.

See also
Director::setContentScaleFactor()
Scheduler* getScheduler ( ) const
inline

Gets the Scheduler associated with this director.

Since
v2.0
var getScheduler ( )
inline

Gets the Scheduler associated with this director.

Since
v2.0
local getScheduler ( )
inline

Gets the Scheduler associated with this director.

Since
v2.0
void setScheduler ( Scheduler scheduler)

Sets the Scheduler associated with this director.

Since
v2.0
var setScheduler ( var  scheduler)

Sets the Scheduler associated with this director.

Since
v2.0
local setScheduler ( local  scheduler)

Sets the Scheduler associated with this director.

Since
v2.0
ActionManager* getActionManager ( ) const
inline

Gets the ActionManager associated with this director.

Since
v2.0
var getActionManager ( )
inline

Gets the ActionManager associated with this director.

Since
v2.0
local getActionManager ( )
inline

Gets the ActionManager associated with this director.

Since
v2.0
void setActionManager ( ActionManager actionManager)

Sets the ActionManager associated with this director.

Since
v2.0
var setActionManager ( var  actionManager)

Sets the ActionManager associated with this director.

Since
v2.0
local setActionManager ( local  actionManager)

Sets the ActionManager associated with this director.

Since
v2.0
EventDispatcher* getEventDispatcher ( ) const
inline

Gets the EventDispatcher associated with this director.

Since
v3.0
local getEventDispatcher ( )
inline

Gets the EventDispatcher associated with this director.

Since
v3.0
void setEventDispatcher ( EventDispatcher dispatcher)

Sets the EventDispatcher associated with this director.

Since
v3.0
local setEventDispatcher ( local  dispatcher)

Sets the EventDispatcher associated with this director.

Since
v3.0
Renderer* getRenderer ( ) const
inline

Returns the Renderer associated with this director.

Since
v3.0
var getRenderer ( )
inline

Returns the Renderer associated with this director.

Since
v3.0
local getRenderer ( )
inline

Returns the Renderer associated with this director.

Since
v3.0
Console* getConsole ( ) const
inline

Returns the Console associated with this director.

Since
v3.0
local getConsole ( )
inline

Returns the Console associated with this director.

Since
v3.0
void pushProjectionMatrix ( size_t  index)

Clones a projection matrix and put it to the top of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
local pushProjectionMatrix ( local  index)

Clones a projection matrix and put it to the top of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
void popProjectionMatrix ( size_t  index)

Pops the top matrix of the projection matrix stack.

Parameters
indexThe index of projection matrix stack.
local popProjectionMatrix ( local  index)

Pops the top matrix of the projection matrix stack.

Parameters
indexThe index of projection matrix stack.
void loadProjectionIdentityMatrix ( size_t  index)

Adds an identity matrix to the top of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
local loadProjectionIdentityMatrix ( local  index)

Adds an identity matrix to the top of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
void loadMatrix ( MATRIX_STACK_TYPE  type,
const Mat4 mat 
)

Adds a matrix to the top of specified type of matrix stack.

Parameters
typeMatrix type.
matThe matrix that to be added.
local loadMatrix ( local  type,
local  mat 
)

Adds a matrix to the top of specified type of matrix stack.

Parameters
typeMatrix type.
matThe matrix that to be added.
void loadProjectionMatrix ( const Mat4 mat,
size_t  index 
)

Adds a matrix to the top of projection matrix stack.

Parameters
matThe matrix that to be added.
indexThe index of projection matrix stack.
local loadProjectionMatrix ( local  mat,
local  index 
)

Adds a matrix to the top of projection matrix stack.

Parameters
matThe matrix that to be added.
indexThe index of projection matrix stack.
void multiplyMatrix ( MATRIX_STACK_TYPE  type,
const Mat4 mat 
)

Multiplies a matrix to the top of specified type of matrix stack.

Parameters
typeMatrix type.
matThe matrix that to be multiplied.
local multiplyMatrix ( local  type,
local  mat 
)

Multiplies a matrix to the top of specified type of matrix stack.

Parameters
typeMatrix type.
matThe matrix that to be multiplied.
void multiplyProjectionMatrix ( const Mat4 mat,
size_t  index 
)

Multiplies a matrix to the top of projection matrix stack.

Parameters
matThe matrix that to be multiplied.
indexThe index of projection matrix stack.
local multiplyProjectionMatrix ( local  mat,
local  index 
)

Multiplies a matrix to the top of projection matrix stack.

Parameters
matThe matrix that to be multiplied.
indexThe index of projection matrix stack.
const Mat4& getProjectionMatrix ( size_t  index) const

Gets the top matrix of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
local getProjectionMatrix ( local  index)

Gets the top matrix of projection matrix stack.

Parameters
indexThe index of projection matrix stack.
void initProjectionMatrixStack ( size_t  stackCount)

Init the projection matrix stack.

Parameters
stackCountThe size of projection matrix stack.
local initProjectionMatrixStack ( local  stackCount)

Init the projection matrix stack.

Parameters
stackCountThe size of projection matrix stack.
const std::thread::id&
getCocos2dThreadId
( ) const
inline

returns the cocos2d thread id.

Useful to know if certain code is already running on the cocos2d thread

var getCocos2dThreadId ( )
inline

returns the cocos2d thread id.

Useful to know if certain code is already running on the cocos2d thread

local getCocos2dThreadId ( )
inline

returns the cocos2d thread id.

Useful to know if certain code is already running on the cocos2d thread

Member Data Documentation

const char*
EVENT_BEFORE_SET_NEXT_SCENE
static

Director will trigger an event before set next scene.

var EVENT_BEFORE_SET_NEXT_SCENE
static

Director will trigger an event before set next scene.

local EVENT_BEFORE_SET_NEXT_SCENE
static

Director will trigger an event before set next scene.

const char*
EVENT_AFTER_SET_NEXT_SCENE
static

Director will trigger an event after set next scene.

var EVENT_AFTER_SET_NEXT_SCENE
static

Director will trigger an event after set next scene.

local EVENT_AFTER_SET_NEXT_SCENE
static

Director will trigger an event after set next scene.

const char*
EVENT_PROJECTION_CHANGED
static

Director will trigger an event when projection type is changed.

var EVENT_PROJECTION_CHANGED
static

Director will trigger an event when projection type is changed.

local EVENT_PROJECTION_CHANGED
static

Director will trigger an event when projection type is changed.

const char* EVENT_BEFORE_UPDATE
static

Director will trigger an event before Schedule::update() is invoked.

var EVENT_BEFORE_UPDATE
static

Director will trigger an event before Schedule::update() is invoked.

local EVENT_BEFORE_UPDATE
static

Director will trigger an event before Schedule::update() is invoked.

const char* EVENT_AFTER_UPDATE
static

Director will trigger an event after Schedule::update() is invoked.

var EVENT_AFTER_UPDATE
static

Director will trigger an event after Schedule::update() is invoked.

local EVENT_AFTER_UPDATE
static

Director will trigger an event after Schedule::update() is invoked.

const char* EVENT_AFTER_VISIT
static

Director will trigger an event after Scene::render() is invoked.

var EVENT_AFTER_VISIT
static

Director will trigger an event after Scene::render() is invoked.

local EVENT_AFTER_VISIT
static

Director will trigger an event after Scene::render() is invoked.

const char* EVENT_AFTER_DRAW
static

Director will trigger an event after a scene is drawn, the data is sent to GPU.

var EVENT_AFTER_DRAW
static

Director will trigger an event after a scene is drawn, the data is sent to GPU.

local EVENT_AFTER_DRAW
static

Director will trigger an event after a scene is drawn, the data is sent to GPU.

const char* EVENT_BEFORE_DRAW
static

Director will trigger an event before a scene is drawn, right after clear.

var EVENT_BEFORE_DRAW
static

Director will trigger an event before a scene is drawn, right after clear.

local EVENT_BEFORE_DRAW
static

Director will trigger an event before a scene is drawn, right after clear.


The documentation for this class was generated from the following file: