Class CCDirector

#include <Geode/cocos/CCDirector.h>
classCCDirector:publiccocos2d::CCObject,publiccocos2d::TypeInfo{ ... }

Class that creates and handle the main Window and manages how and when to execute the Scenes. The CCDirector is also responsible for:

  • initializing the OpenGL context
  • 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 Portrait) Since the CCDirector is a singleton, the standard way to use it is by calling: _ CCDirector::sharedDirector()->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
Examples0
Public static methods2
staticcocos2d::CCDirector*get()
No description provided
staticcocos2d::CCDirector*sharedDirector()

returns a shared instance of the director

Public member functions106
virtualboolinit()
No description provided
virtuallonggetClassTypeInfo()
No description provided
cocos2d::CCScene*getRunningScene()

Get current running Scene. Director can only run one Scene at the time

doublegetAnimationInterval()

Get the FPS value

virtualvoidsetAnimationInterval(
doubledValue
)

Set the FPS value.

boolisDisplayStats()

Whether or not to display the FPS on the bottom-left corner

voidsetDisplayStats(
boolbDisplayStats
)

Display the FPS on the bottom-left corner

floatgetSecondsPerFrame()

seconds per frame

cocos2d::CCEGLView*getOpenGLView()

Get the CCEGLView, where everything is rendered

voidsetOpenGLView(
cocos2d::CCEGLView*pobOpenGLView
)
No description provided
boolisNextDeltaTimeZero()
No description provided
voidsetNextDeltaTimeZero(
boolbNextDeltaTimeZero
)
No description provided
boolisPaused()

Whether or not the Director is paused

voidsetPaused()
No description provided
uintgetTotalFrames()

How many frames were called since the director started

cocos2d::ccDirectorProjectiongetProjection()

Since v0.8.2

Sets an OpenGL projection

voidsetProjection()
No description provided
voidreshapeProjection()

reshape projection matrix when canvas has been change“

voidsetViewport()

Sets the glViewport

boolisSendCleanupToScene()

Since v0.99.0

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.

cocos2d::CCNode*getNotificationNode()

Since v0.99.5

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)

voidsetNotificationNode()
No description provided
cocos2d::CCDirectorDelegate*getDelegate()const

Since v0.99.5

CCDirector delegate. It shall implemente the CCDirectorDelegate protocol

voidsetDelegate()
No description provided
cocos2d::CCSizegetWinSize()

returns the size of the OpenGL view in points.

cocos2d::CCSizegetWinSizeInPixels()

returns the size of the OpenGL view in pixels.

cocos2d::CCSizegetVisibleSize()

returns visible size of the OpenGL view in points. the value is equal to getWinSize if don’t invoke CCEGLView::setDesignResolutionSize()

cocos2d::CCPointgetVisibleOrigin()

returns visible origin of the OpenGL view in points.

cocos2d::CCPointconvertToGL()

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

cocos2d::CCPointconvertToUI()

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

floatgetZEye()

/// XXX: missing description

voidrunWithScene()

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

boolpushScene()

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.

ℹ Robtop Addition: return value from void to bool

voidpopScene()

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.

voidpopToRootScene()

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)

voidpopToSceneStackLevel(
intlevel
)

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.

boolreplaceScene()

Replaces the running scene with a new one. The running scene is terminated. ONLY call it if there is a running scene.

ℹ Robtop Addition: return value from void to bool

voidend()

Ends the execution, releases the running scene. It doesn’t remove the OpenGL view from its parent. You have to do it manually.

voidpause()

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

voidresume()

Resumes the paused scene The scheduled timers will be activated again. The “delta time” will be 0 (as if the game wasn’t paused)

voiddrawScene()

Draw the scene. This method is called every frame. Don’t call it manually.

voidpurgeCachedData()

Since v0.99.3

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

voidsetDefaultValues()

sets the default values based on the CCConfiguration info

voidsetGLDefaultValues()

sets the OpenGL default values

voidsetAlphaBlending(
boolbOn
)

enables/disables OpenGL alpha blending

voidsetDepthTest(
boolbOn
)

enables/disables OpenGL depth test

voidsetContentScaleFactor(
floatscaleFactor
)

Since v0.99.4

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.

floatgetContentScaleFactor()
No description provided
voidcheckSceneReference()
No description provided
cocos2d::CCScene*getNextScene()
No description provided
intlevelForSceneInStack()
No description provided
boolpopSceneWithTransition(,)
No description provided
voidpopToSceneInStack()
No description provided
intsceneCount()
No description provided
voidwillSwitchToScene()
No description provided
voidremoveStatsLabel()
No description provided
voidresetSmoothFixCounter()
No description provided
voidsetDeltaTime()
No description provided
voidsetupScreenScale(,,)
No description provided
voidupdateContentScale()
No description provided
voidupdateScreenScale()
No description provided
voidapplySmoothFix()
No description provided
voidshowFPSLabel()
No description provided
voidtoggleShowFPS(,,)
No description provided
floatgetScreenScaleFactor()const
No description provided
floatgetScreenScaleFactorMax()const
No description provided
floatgetScreenScaleFactorW()const
No description provided
floatgetScreenScaleFactorH()const
No description provided
floatgetScreenTop()const
No description provided
floatgetScreenBottom()
No description provided
floatgetScreenLeft()
No description provided
floatgetScreenRight()const
No description provided
cocos2d::CCScene*getSceneReference()const
No description provided
voidsetSceneReference()
No description provided
virtualcocos2d::CCScheduler*getScheduler()

Since v2.0

CCScheduler associated with this director

virtualvoidsetScheduler()

Since v2.0

CCScheduler associated with this director

virtualcocos2d::CCActionManager*getActionManager()

Since v2.0

CCActionManager associated with this director

virtualvoidsetActionManager()

Since v2.0

CCActionManager associated with this director

virtualcocos2d::CCTouchDispatcher*getTouchDispatcher()

Since v2.0

CCTouchDispatcher associated with this director

virtualvoidsetTouchDispatcher()

Since v2.0

CCTouchDispatcher associated with this director

virtualcocos2d::CCKeypadDispatcher*getKeypadDispatcher()

Since v2.0

CCKeypadDispatcher associated with this director

virtualvoidsetKeypadDispatcher()

Since v2.0

CCKeypadDispatcher associated with this director

virtualcocos2d::CCKeyboardDispatcher*getKeyboardDispatcher()
No description provided
virtualvoidsetKeyboardDispatcher()
No description provided
virtualcocos2d::CCMouseDispatcher*getMouseDispatcher()
No description provided
virtualvoidsetMouseDispatcher()
No description provided
virtualcocos2d::CCAccelerometer*getAccelerometer()

Since v2.0

CCAccelerometer associated with this director

virtualvoidsetAccelerometer()

Since v2.0

CCAccelerometer associated with this director

virtualfloatgetDeltaTime()
No description provided
floatgetActualDeltaTime()const
No description provided
voidsetActualDeltaTime()
No description provided
boolgetIsTransitioning()const
No description provided
boolgetSmoothFix()const
No description provided
voidsetSmoothFix(
boolvar
)
No description provided
boolgetSmoothFixCheck()const
No description provided
voidsetSmoothFixCheck(
boolvar
)
No description provided
boolgetForceSmoothFix()const
No description provided
voidsetForceSmoothFix(
boolvar
)
No description provided
intgetSmoothFixCounter()const
No description provided
virtualcocos2d::CCSceneDelegate*getSceneDelegate()const
No description provided
virtualvoidsetSceneDelegate()
No description provided
cocos2d::TextureQualitygetLoadedTextureQuality()const
No description provided
boolgetDontCallWillSwitch()const
No description provided
voidsetDontCallWillSwitch(
boolvar
)
No description provided
boolgetFastMenu()const
No description provided
voidsetFastMenu(
boolvar
)
No description provided
Fields33
boolm_bPurgeDirecotorInNextLoop
;
No description provided
cocos2d::CCEGLView*m_pobOpenGLView
;
No description provided
doublem_dAnimationInterval
;
No description provided
doublem_dOldAnimationInterval
;
No description provided
boolm_bLandscape
;
No description provided
boolm_bDisplayStats
;
No description provided
floatm_fFpsAccumDt
;
No description provided
floatm_fAccumDt
;
No description provided
floatm_fFrameRate
;
No description provided
;
No description provided
;
No description provided
;
No description provided
boolm_bPaused
;

Whether or not the Director is paused

uintm_uTotalFrames
;
No description provided
uintm_uFrames
;
No description provided
floatm_fSecondsPerFrame
;
No description provided
cocos2d::CCScene*m_pRunningScene
;
No description provided
cocos2d::CCScene*m_pNextScene
;
No description provided
boolm_bSendCleanupToScene
;
No description provided
cocos2d::CCArray*m_pobScenesStack
;
No description provided
;
No description provided
boolm_bNextDeltaTimeZero
;
No description provided
;
No description provided
cocos2d::CCSizem_obWinSizeInPoints
;
No description provided
floatm_fContentScaleFactor
;
No description provided
char*m_pszFPS
;
No description provided
cocos2d::CCNode*m_pNotificationNode
;
No description provided
cocos2d::CCDirectorDelegate*m_pProjectionDelegate
;
No description provided
boolm_bDisplayFPS
;
No description provided
;
No description provided
cocos2d::CCSizem_obScaleFactor
;
No description provided
cocos2d::CCSizem_obResolutionInPixels
;
No description provided
void*m_unknownPtr3
;
No description provided
Protected member functions10
virtualvoidstopAnimation()

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.

virtualvoidstartAnimation()

The main loop is triggered again. Call this function only if [stopAnimation] was called earlier

⚠️ Don't call this function to start the main loop. To run the main loop call runWithScene

virtualvoidmainLoop()
No description provided
voidcreateStatsLabel()
No description provided
voidpurgeDirector()
No description provided
voidsetNextScene()
No description provided
voidshowStats()
No description provided
voidcalculateMPF()
No description provided
voidgetFPSImageData(
unsigned char **datapointer
,
uint*length
)
No description provided
voidcalculateDeltaTime()

calculates delta time since last time it was called

Protected fields27
floatm_fScreenScaleFactor
;
No description provided
floatm_fScreenScaleFactorMax
;
No description provided
floatm_fScreenScaleFactorW
;
No description provided
floatm_fScreenScaleFactorH
;
No description provided
floatm_fScreenTop
;
No description provided
floatm_fScreenBottom
;
No description provided
floatm_fScreenLeft
;
No description provided
floatm_fScreenRight
;
No description provided
cocos2d::CCScene*m_pSceneReference
;
No description provided
;

Since v2.0

CCScheduler associated with this director

;

Since v2.0

CCActionManager associated with this director

cocos2d::CCTouchDispatcher*m_pTouchDispatcher
;

Since v2.0

CCTouchDispatcher associated with this director

cocos2d::CCKeypadDispatcher*m_pKeypadDispatcher
;

Since v2.0

CCKeypadDispatcher associated with this director

cocos2d::CCKeyboardDispatcher*m_pKeyboardDispatcher
;
No description provided
cocos2d::CCMouseDispatcher*m_pMouseDispatcher
;
No description provided
;

Since v2.0

CCAccelerometer associated with this director

floatm_fDeltaTime
;
No description provided
floatm_fActualDeltaTime
;
No description provided
boolm_bIsTransitioning
;
No description provided
boolm_bSmoothFix
;
No description provided
boolm_bSmoothFixCheck
;
No description provided
boolm_bForceSmoothFix
;
No description provided
intm_nSmoothFixCounter
;
No description provided
;
No description provided
cocos2d::TextureQualitym_eTextureQuality
;
No description provided
boolm_bDontCallWillSwitch
;
No description provided
boolm_bFastMenu
;
No description provided