summary refs log tree commit diff stats
path: root/libs/cocos2d/Platforms/iOS/CCDirectorIOS.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cocos2d/Platforms/iOS/CCDirectorIOS.h')
-rwxr-xr-xlibs/cocos2d/Platforms/iOS/CCDirectorIOS.h255
1 files changed, 255 insertions, 0 deletions
diff --git a/libs/cocos2d/Platforms/iOS/CCDirectorIOS.h b/libs/cocos2d/Platforms/iOS/CCDirectorIOS.h new file mode 100755 index 0000000..1c264e4 --- /dev/null +++ b/libs/cocos2d/Platforms/iOS/CCDirectorIOS.h
@@ -0,0 +1,255 @@
1/*
2 * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 *
4 * Copyright (c) 2008-2010 Ricardo Quesada
5 * Copyright (c) 2011 Zynga Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26
27// Only compile this code on iOS. These files should NOT be included on your Mac project.
28// But in case they are included, it won't be compiled.
29#import <Availability.h>
30#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
31
32#import "../../CCDirector.h"
33
34/** @typedef ccDeviceOrientation
35 Possible device orientations
36 */
37typedef enum {
38 /// Device oriented vertically, home button on the bottom
39 kCCDeviceOrientationPortrait = UIDeviceOrientationPortrait,
40 /// Device oriented vertically, home button on the top
41 kCCDeviceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
42 /// Device oriented horizontally, home button on the right
43 kCCDeviceOrientationLandscapeLeft = UIDeviceOrientationLandscapeLeft,
44 /// Device oriented horizontally, home button on the left
45 kCCDeviceOrientationLandscapeRight = UIDeviceOrientationLandscapeRight,
46
47 // Backward compatibility stuff
48 CCDeviceOrientationPortrait = kCCDeviceOrientationPortrait,
49 CCDeviceOrientationPortraitUpsideDown = kCCDeviceOrientationPortraitUpsideDown,
50 CCDeviceOrientationLandscapeLeft = kCCDeviceOrientationLandscapeLeft,
51 CCDeviceOrientationLandscapeRight = kCCDeviceOrientationLandscapeRight,
52} ccDeviceOrientation;
53
54/** @typedef ccDirectorType
55 Possible Director Types.
56 @since v0.8.2
57 */
58typedef enum {
59 /** Will use a Director that triggers the main loop from an NSTimer object
60 *
61 * Features and Limitations:
62 * - Integrates OK with UIKit objects
63 * - It the slowest director
64 * - The invertal update is customizable from 1 to 60
65 */
66 kCCDirectorTypeNSTimer,
67
68 /** will use a Director that triggers the main loop from a custom main loop.
69 *
70 * Features and Limitations:
71 * - Faster than NSTimer Director
72 * - It doesn't integrate well with UIKit objecgts
73 * - The interval update can't be customizable
74 */
75 kCCDirectorTypeMainLoop,
76
77 /** Will use a Director that triggers the main loop from a thread, but the main loop will be executed on the main thread.
78 *
79 * Features and Limitations:
80 * - Faster than NSTimer Director
81 * - It doesn't integrate well with UIKit objecgts
82 * - The interval update can't be customizable
83 */
84 kCCDirectorTypeThreadMainLoop,
85
86 /** Will use a Director that synchronizes timers with the refresh rate of the display.
87 *
88 * Features and Limitations:
89 * - Faster than NSTimer Director
90 * - Only available on 3.1+
91 * - Scheduled timers & drawing are synchronizes with the refresh rate of the display
92 * - Integrates OK with UIKit objects
93 * - The interval update can be 1/60, 1/30, 1/15
94 */
95 kCCDirectorTypeDisplayLink,
96
97 /** Default director is the NSTimer directory */
98 kCCDirectorTypeDefault = kCCDirectorTypeNSTimer,
99
100 // backward compatibility stuff
101 CCDirectorTypeNSTimer = kCCDirectorTypeNSTimer,
102 CCDirectorTypeMainLoop = kCCDirectorTypeMainLoop,
103 CCDirectorTypeThreadMainLoop = kCCDirectorTypeThreadMainLoop,
104 CCDirectorTypeDisplayLink = kCCDirectorTypeDisplayLink,
105 CCDirectorTypeDefault = kCCDirectorTypeDefault,
106
107
108} ccDirectorType;
109
110/** CCDirector extensions for iPhone
111 */
112@interface CCDirector (iOSExtension)
113
114// rotates the screen if an orientation differnent than Portrait is used
115-(void) applyOrientation;
116
117/** Sets the device orientation.
118 If the orientation is going to be controlled by an UIViewController, then the orientation should be Portrait
119 */
120-(void) setDeviceOrientation:(ccDeviceOrientation)orientation;
121
122/** returns the device orientation */
123-(ccDeviceOrientation) deviceOrientation;
124
125/** The size in pixels of the surface. It could be different than the screen size.
126 High-res devices might have a higher surface size than the screen size.
127 In non High-res device the contentScale will be emulated.
128
129 The recommend way to enable Retina Display is by using the "enableRetinaDisplay:(BOOL)enabled" method.
130
131 @since v0.99.4
132 */
133-(void) setContentScaleFactor:(CGFloat)scaleFactor;
134
135/** Will enable Retina Display on devices that supports it.
136 It will enable Retina Display on iPhone4 and iPod Touch 4.
137 It will return YES, if it could enabled it, otherwise it will return NO.
138
139 This is the recommened way to enable Retina Display.
140 @since v0.99.5
141 */
142-(BOOL) enableRetinaDisplay:(BOOL)yes;
143
144
145/** returns the content scale factor */
146-(CGFloat) contentScaleFactor;
147@end
148
149@interface CCDirector (iOSExtensionClassMethods)
150
151/** There are 4 types of Director.
152 - kCCDirectorTypeNSTimer (default)
153 - kCCDirectorTypeMainLoop
154 - kCCDirectorTypeThreadMainLoop
155 - kCCDirectorTypeDisplayLink
156
157 Each Director has it's own benefits, limitations.
158 If you are using SDK 3.1 or newer it is recommed to use the DisplayLink director
159
160 This method should be called before any other call to the director.
161
162 It will return NO if the director type is kCCDirectorTypeDisplayLink and the running SDK is < 3.1. Otherwise it will return YES.
163
164 @since v0.8.2
165 */
166+(BOOL) setDirectorType:(ccDirectorType) directorType;
167@end
168
169#pragma mark -
170#pragma mark CCDirectorIOS
171
172/** CCDirectorIOS: Base class of iOS directors
173 @since v0.99.5
174 */
175@interface CCDirectorIOS : CCDirector
176{
177 /* orientation */
178 ccDeviceOrientation deviceOrientation_;
179
180 /* contentScaleFactor could be simulated */
181 BOOL isContentScaleSupported_;
182
183}
184@end
185
186/** FastDirector is a Director that triggers the main loop as fast as possible.
187 *
188 * Features and Limitations:
189 * - Faster than "normal" director
190 * - Consumes more battery than the "normal" director
191 * - It has some issues while using UIKit objects
192 */
193@interface CCDirectorFast : CCDirectorIOS
194{
195 BOOL isRunning;
196
197 NSAutoreleasePool *autoreleasePool;
198}
199-(void) mainLoop;
200@end
201
202/** ThreadedFastDirector is a Director that triggers the main loop from a thread.
203 *
204 * Features and Limitations:
205 * - Faster than "normal" director
206 * - Consumes more battery than the "normal" director
207 * - It can be used with UIKit objects
208 *
209 * @since v0.8.2
210 */
211@interface CCDirectorFastThreaded : CCDirectorIOS
212{
213 BOOL isRunning;
214}
215-(void) mainLoop;
216@end
217
218/** DisplayLinkDirector is a Director that synchronizes timers with the refresh rate of the display.
219 *
220 * Features and Limitations:
221 * - Only available on 3.1+
222 * - Scheduled timers & drawing are synchronizes with the refresh rate of the display
223 * - Only supports animation intervals of 1/60 1/30 & 1/15
224 *
225 * It is the recommended Director if the SDK is 3.1 or newer
226 *
227 * @since v0.8.2
228 */
229@interface CCDirectorDisplayLink : CCDirectorIOS
230{
231 id displayLink;
232}
233-(void) mainLoop:(id)sender;
234@end
235
236/** TimerDirector is a Director that calls the main loop from an NSTimer object
237 *
238 * Features and Limitations:
239 * - Integrates OK with UIKit objects
240 * - It the slowest director
241 * - The invertal update is customizable from 1 to 60
242 *
243 * It is the default Director.
244 */
245@interface CCDirectorTimer : CCDirectorIOS
246{
247 NSTimer *animationTimer;
248}
249-(void) mainLoop;
250@end
251
252// optimization. Should only be used to read it. Never to write it.
253extern CGFloat __ccContentScaleFactor;
254
255#endif // __IPHONE_OS_VERSION_MAX_ALLOWED