cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
Public Member Functions | Static Public Member Functions | Properties
CCDirector Class Reference

#import <CCDirector.h>

Collaboration diagram for CCDirector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(CGSize) - winSize
(CGSize) - winSizeInPixels
(CGSize) - displaySizeInPixels
(void) - reshapeProjection:
(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:

Static Public Member Functions

(CCDirector *) + sharedDirector

Properties

NSThread * runningThread
CCScenerunningScene
NSTimeInterval animationInterval
BOOL displayFPS
CC_GLVIEW * openGLView
BOOL nextDeltaTimeZero
BOOL isPaused
ccDirectorProjection projection
NSUInteger frames
BOOL sendCleanupToScene
id notificationNode
id< CCProjectionProtocolprojectionDelegate

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 context:

Definition at line 80 of file CCDirector.h.


Member Function Documentation

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

- (CGSize) displaySizeInPixels

returns the display size of the OpenGL view in pixels. It doesn't take into account any possible rotation of the window.

- (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, CCLabelBMFont 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) 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) reshapeProjection: (CGSize)  newWindowSize

changes the projection size

- (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) setDepthTest: (BOOL)  on

enables/disables OpenGL depth test

- (void) setGLDefaultValues

sets the OpenGL default values

+ (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 points. It takes into account any possible rotation (device orientation) of the window

- (CGSize) winSizeInPixels

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.


Property Documentation

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

The FPS value

Definition at line 154 of file CCDirector.h.

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

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

Definition at line 156 of file CCDirector.h.

- (NSUInteger) frames [read, assign]

How many frames were called since the director started

Definition at line 168 of file CCDirector.h.

- (BOOL) isPaused [read, assign]

Whether or not the Director is paused

Definition at line 162 of file CCDirector.h.

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

whether or not the next delta time will be zero

Definition at line 160 of file CCDirector.h.

- (id) notificationNode [read, write, retain]

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)

Since:
v0.99.5

Definition at line 182 of file CCDirector.h.

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

The OpenGLView, where everything is rendered

Definition at line 158 of file CCDirector.h.

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

Sets an OpenGL projection

Since:
v0.8.2

Definition at line 166 of file CCDirector.h.

- (id<CCProjectionProtocol>) projectionDelegate [read, write, retain]

This object will be called when the OpenGL projection is udpated and only when the kCCDirectorProjectionCustom projection is used.

Since:
v0.99.5

Definition at line 187 of file CCDirector.h.

- (CCScene*) runningScene [read, assign]

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

Definition at line 152 of file CCDirector.h.

- (NSThread*) runningThread [read, assign]

returns the cocos2d thread. If you want to run any cocos2d task, run it in this thread. On iOS usually it is the main thread.

Since:
v0.99.5

Definition at line 150 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 175 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 API Reference - Generated using Doxygen 1.7.4