Public Member Functions | Static Public Member Functions | Properties

CCDirector Class Reference

#import <CCDirector.h>

Inherited by CCDisplayLinkDirector, CCFastDirector, CCThreadedFastDirector, and CCTimerDirector.

Collaboration diagram for CCDirector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(void) - setPixelFormat:
(void) - setDepthBufferFormat:
(BOOL) - DEPRECATED_ATTRIBUTE
(BOOL) - attachInWindow:
(BOOL) - attachInView:
(BOOL) - attachInView:withFrame:
(CGSize) - winSize
(CGSize) - displaySize
(CGPoint) - convertToGL:
(CGPoint) - convertToUI:
(float) - getZEye
 XXX: missing description.
(void) - runWithScene:
(void) - pushScene:
(void) - popScene
(void) - replaceScene:
(void) - end
(void) - pause
(void) - resume
(void) - stopAnimation
(void) - startAnimation
(void) - drawScene
(void) - purgeCachedData
(void) - setGLDefaultValues
(void) - setAlphaBlending:
(void) - setDepthTest:
(void) - recalculateProjectionAndEAGLViewSize

Static Public Member Functions

(CCDirector *) + sharedDirector
(BOOL) + setDirectorType:

Properties

CCScenerunningScene
NSTimeInterval animationInterval
BOOL displayFPS
EAGLViewopenGLView
tPixelFormat pixelFormat DEPRECATED_ATTRIBUTE
BOOL nextDeltaTimeZero
ccDeviceOrientation deviceOrientation
BOOL isPaused
ccDirectorProjection projection
BOOL sendCleanupToScene
CGFloat contentScaleFactor

Detailed Description

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

The CCDirector is also resposible for:

Since the CCDirector is a singleton, the standard way to use it is by calling:

The CCDirector also sets the default OpenGL ES context:

Definition at line 190 of file CCDirector.h.


Member Function Documentation

- (BOOL) attachInView: (UIView *)  DEPRECATED_ATTRIBUTE  

attach in UIView using the full frame. It will create a EAGLView.

Deprecated:
set setOpenGLView instead. Will be removed in v1.0
- (BOOL) attachInView: (UIView *)  view
withFrame: (CGRect)  DEPRECATED_ATTRIBUTE 

attach in UIView using the given frame. It will create a EAGLView and use it.

Deprecated:
set setOpenGLView instead. Will be removed in v1.0
- (BOOL) attachInWindow: (UIWindow *)  DEPRECATED_ATTRIBUTE  

attach in UIWindow using the full frame. It will create a EAGLView.

Deprecated:
set setOpenGLView instead. Will be removed in v1.0
- (CGPoint) convertToGL: (CGPoint)  p  

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

- (CGPoint) convertToUI: (CGPoint)  p  

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

- (BOOL) DEPRECATED_ATTRIBUTE  

detach the cocos2d view from the view/window

- (CGSize) displaySize  

returns the display size of the OpenGL view in pixels

- (void) drawScene  

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

- (void) end  

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

- (float) getZEye  

XXX: missing description.

- (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 consuption

- (void) 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.

- (void) purgeCachedData  

Removes all the cocos2d data that was cached automatically. It will purge the CCTextureCache, CCBitmapFont cache. IMPORTANT: The CCSpriteFrameCache won't be purged. If you want to purge it, you have to purge it manually.

Since:
v0.99.3
- (void) pushScene: (CCScene *)  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) recalculateProjectionAndEAGLViewSize  

recalculate the projection view and projection size based on the EAGLVIEW

Since:
v0.99.4
- (void) replaceScene: (CCScene *)  scene  

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

- (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)

- (void) runWithScene: (CCScene *)  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.

- (void) setAlphaBlending: (BOOL)  on  

enables/disables OpenGL alpha blending

- (void) setDepthBufferFormat: (tDepthBufferFormat)  DEPRECATED_ATTRIBUTE  

Change depth buffer format of the render buffer. Call this class method before attaching it to a UIWindow/UIView Default depth buffer: 0 (none). Supported: kCCDepthBufferNone, kCCDepthBuffer16, and kCCDepthBuffer24

Deprecated:
Set the depth buffer format when creating the EAGLView. This method will be removed in v1.0
- (void) setDepthTest: (BOOL)  on  

enables/disables OpenGL depth test

+ (BOOL) setDirectorType: (ccDirectorType)  directorType  

There are 4 types of Director.

  • kCCDirectorTypeNSTimer (default)
  • kCCDirectorTypeMainLoop
  • kCCDirectorTypeThreadMainLoop
  • kCCDirectorTypeDisplayLink

Each Director has it's own benefits, limitations. If you are using SDK 3.1 or newer it is recommed to use the DisplayLink director

This method should be called before any other call to the director.

It will return NO if the director type is kCCDirectorTypeDisplayLink and the running SDK is < 3.1. Otherwise it will return YES.

Since:
v0.8.2
- (void) setGLDefaultValues  

sets the OpenGL default values

- (void) setPixelFormat: (tPixelFormat)  DEPRECATED_ATTRIBUTE  

Uses a new pixel format for the EAGLView. Call this class method before attaching it to a UIView Default pixel format: kRGB565. Supported pixel formats: kRGBA8 and kRGB565

Deprecated:
Set the pixel format when creating the EAGLView. This method will be removed in v1.0
+ (CCDirector *) sharedDirector  

returns a shared instance of the director

- (void) startAnimation  

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

Warning:
Dont' call this function to start the main loop. To run the main loop call runWithScene
- (void) stopAnimation  

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

- (CGSize) winSize  

returns the size of the OpenGL view in pixels, according to the landspace


Property Documentation

- (NSTimeInterval) animationInterval [read, write, assign]

The FPS value

Definition at line 260 of file CCDirector.h.

- (CGFloat) contentScaleFactor [read, write, assign]

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. In non High-res device the contentScale will be emulated.

Warning: Emulation of High-Res on iOS < 4 is an EXPERIMENTAL feature.

Since:
v0.99.4

Definition at line 293 of file CCDirector.h.

- (tPixelFormat pixelFormat) DEPRECATED_ATTRIBUTE [read, assign]

Pixel format used to create the context

Definition at line 266 of file CCDirector.h.

- (ccDeviceOrientation) deviceOrientation [read, write, assign]

The device orientattion

Definition at line 270 of file CCDirector.h.

- (BOOL) displayFPS [read, write, assign]

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

Definition at line 262 of file CCDirector.h.

- (BOOL) isPaused [read, assign]

Whether or not the Director is paused

Definition at line 272 of file CCDirector.h.

- (BOOL) nextDeltaTimeZero [read, write, assign]

whether or not the next delta time will be zero

Definition at line 268 of file CCDirector.h.

- (EAGLView*) openGLView [read, write, retain]

The EAGLView, where everything is rendered

Definition at line 264 of file CCDirector.h.

- (ccDirectorProjection) projection [read, write, assign]

Sets an OpenGL projection

Since:
v0.8.2

Definition at line 276 of file CCDirector.h.

- (CCScene*) runningScene [read, assign]

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

Definition at line 258 of file CCDirector.h.

- (BOOL) sendCleanupToScene [read, assign]

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

Definition at line 283 of file CCDirector.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone 0.99.4 API Reference - Generated using Doxygen 1.7.1