cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocos2d/CCDirector.h
00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2008-2010 Ricardo Quesada
00005  * Copyright (c) 2011 Zynga Inc.
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  */
00025 
00026 
00027 #import "ccConfig.h"
00028 #import "ccTypes.h"
00029 
00030 // OpenGL related
00031 #import "Platforms/CCGL.h"
00032 #import "CCProtocols.h"
00033 
00037 typedef enum {
00039         kCCDirectorProjection2D,
00040         
00042         kCCDirectorProjection3D,
00043         
00045         kCCDirectorProjectionCustom,
00046         
00048         kCCDirectorProjectionDefault = kCCDirectorProjection3D,
00049         
00050         // backward compatibility stuff
00051         CCDirectorProjection2D = kCCDirectorProjection2D,
00052         CCDirectorProjection3D = kCCDirectorProjection3D,
00053         CCDirectorProjectionCustom = kCCDirectorProjectionCustom,
00054 
00055 } ccDirectorProjection;
00056 
00057 
00058 @class CCLabelAtlas;
00059 @class CCScene;
00060 
00080 @interface CCDirector : NSObject
00081 {
00082         CC_GLVIEW       *openGLView_;
00083 
00084         // internal timer
00085         NSTimeInterval animationInterval_;
00086         NSTimeInterval oldAnimationInterval_;   
00087         
00088         /* display FPS ? */
00089         BOOL displayFPS_;
00090 
00091         NSUInteger frames_;
00092         ccTime accumDt_;
00093         ccTime frameRate_;
00094 #if     CC_DIRECTOR_FAST_FPS
00095         CCLabelAtlas *FPSLabel_;
00096 #endif
00097         
00098         /* is the running scene paused */
00099         BOOL isPaused_;
00100         
00101         /* The running scene */
00102         CCScene *runningScene_;
00103         
00104         /* This object will be visited after the scene. Useful to hook a notification node */
00105         id notificationNode_;
00106         
00107         /* will be the next 'runningScene' in the next frame
00108          nextScene is a weak reference. */
00109         CCScene *nextScene_;
00110         
00111         /* If YES, then "old" scene will receive the cleanup message */
00112         BOOL    sendCleanupToScene_;
00113 
00114         /* scheduled scenes */
00115         NSMutableArray *scenesStack_;
00116         
00117         /* last time the main loop was updated */
00118         struct timeval lastUpdate_;
00119         /* delta time since last tick to main loop */
00120         ccTime dt;
00121         /* whether or not the next delta time will be zero */
00122         BOOL nextDeltaTimeZero_;
00123         
00124         /* projection used */
00125         ccDirectorProjection projection_;
00126         
00127         /* Projection protocol delegate */
00128         id<CCProjectionProtocol>        projectionDelegate_;
00129 
00130         /* window size in points */
00131         CGSize  winSizeInPoints_;
00132         
00133         /* window size in pixels */
00134         CGSize  winSizeInPixels_;
00135 
00136         /* the cocos2d running thread */
00137         NSThread        *runningThread_;
00138 
00139         // profiler
00140 #if CC_ENABLE_PROFILERS
00141         ccTime accumDtForProfiler_;
00142 #endif
00143 }
00144 
00150 @property (readonly, nonatomic ) NSThread *runningThread;
00152 @property (nonatomic,readonly) CCScene* runningScene;
00154 @property (nonatomic,readwrite, assign) NSTimeInterval animationInterval;
00156 @property (nonatomic,readwrite, assign) BOOL displayFPS;
00158 @property (nonatomic,readwrite,retain) CC_GLVIEW *openGLView;
00160 @property (nonatomic,readwrite,assign) BOOL nextDeltaTimeZero;
00162 @property (nonatomic,readonly) BOOL isPaused;
00166 @property (nonatomic,readwrite) ccDirectorProjection projection;
00168 @property (readonly) NSUInteger frames;
00169 
00175 @property (nonatomic, readonly) BOOL sendCleanupToScene;
00176 
00182 @property (nonatomic, readwrite, retain) id     notificationNode;
00183 
00187 @property (nonatomic, readwrite, retain) id<CCProjectionProtocol> projectionDelegate;
00188 
00190 +(CCDirector *)sharedDirector;
00191 
00192 
00193 
00194 // Window size
00195 
00199 - (CGSize) winSize;
00200 
00205 - (CGSize) winSizeInPixels;
00209 -(CGSize) displaySizeInPixels;
00211 -(void) reshapeProjection:(CGSize)newWindowSize;
00212 
00216 -(CGPoint) convertToGL: (CGPoint) p;
00220 -(CGPoint) convertToUI:(CGPoint)p;
00221 
00223 -(float) getZEye;
00224 
00225 // Scene Management
00226 
00231 - (void) runWithScene:(CCScene*) scene;
00232 
00238 - (void) pushScene:(CCScene*) scene;
00239 
00245 - (void) popScene;
00246 
00250 -(void) replaceScene: (CCScene*) scene;
00251 
00255 -(void) end;
00256 
00261 -(void) pause;
00262 
00267 -(void) resume;
00268 
00272 -(void) stopAnimation;
00273 
00278 -(void) startAnimation;
00279 
00283 -(void) drawScene;
00284 
00285 // Memory Helper
00286 
00292 -(void) purgeCachedData; 
00293 
00294 // OpenGL Helper
00295 
00297 -(void) setGLDefaultValues;
00298 
00300 - (void) setAlphaBlending: (BOOL) on;
00302 - (void) setDepthTest: (BOOL) on;
00303 
00304 // Profiler
00305 -(void) showProfilers;
00306 
00307 @end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4