Cocos2d-x uses a shared singleton object called Director
. The Director
takes care of initializing OpenGL, Scene transitions, converting coordinates from UIKit to OpenGL and vice versa.
Every Cocos2d-x application has a Director
context that is created as the application is starting. The Director
is created in AppDelegate::applicationDidFinishLaunching()
. As the Director
is a shared singleton it may be interacted with at almost any stage in your game.
Example: Get the visible screen size
cocos2d::Size visibleSize = cocos2d::Director::getInstance()->getVisibleSize();
Example: Replacing a Scene
cocos2d::Director::getInstance()->replaceScene(newScene);
Example: Showing Frames-per-second information in lower left corner
cocos2d::Director::setDisplayStats(true);
Please refer to the API documentation for a complete listing of functionality.
The SpriteFrameCache
is a singleton that handles the loading of the sprite frames. The first time a sprite is called if it doesn't already exist in the cache it is added.
The TextureCache