summary refs log tree commit diff stats
path: root/libs/cocos2d/CCLayer.h
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
committerStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
commit9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch)
tree5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/CCLayer.h
downloadcartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/CCLayer.h')
-rwxr-xr-xlibs/cocos2d/CCLayer.h293
1 files changed, 293 insertions, 0 deletions
diff --git a/libs/cocos2d/CCLayer.h b/libs/cocos2d/CCLayer.h new file mode 100755 index 0000000..f4c9860 --- /dev/null +++ b/libs/cocos2d/CCLayer.h
@@ -0,0 +1,293 @@
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
28
29#import <Availability.h>
30#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
31#import <UIKit/UIKit.h> // Needed for UIAccelerometerDelegate
32#import "Platforms/iOS/CCTouchDelegateProtocol.h" // Touches only supported on iOS
33#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
34#import "Platforms/Mac/CCEventDispatcher.h"
35#endif
36
37#import "CCProtocols.h"
38#import "CCNode.h"
39
40#pragma mark -
41#pragma mark CCLayer
42
43/** CCLayer is a subclass of CCNode that implements the TouchEventsDelegate protocol.
44
45 All features from CCNode are valid, plus the following new features:
46 - It can receive iPhone Touches
47 - It can receive Accelerometer input
48*/
49#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
50@interface CCLayer : CCNode <UIAccelerometerDelegate, CCStandardTouchDelegate, CCTargetedTouchDelegate>
51{
52 BOOL isTouchEnabled_;
53 BOOL isAccelerometerEnabled_;
54}
55/** If isTouchEnabled, this method is called onEnter. Override it to change the
56 way CCLayer receives touch events.
57 ( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] )
58 Example:
59 -(void) registerWithTouchDispatcher
60 {
61 [[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES];
62 }
63
64 Valid only on iOS. Not valid on Mac.
65
66 @since v0.8.0
67 */
68-(void) registerWithTouchDispatcher;
69
70/** whether or not it will receive Touch events.
71 You can enable / disable touch events with this property.
72 Only the touches of this node will be affected. This "method" is not propagated to it's children.
73
74 Valid on iOS and Mac OS X v10.6 and later.
75
76 @since v0.8.1
77 */
78@property(nonatomic,assign) BOOL isTouchEnabled;
79/** whether or not it will receive Accelerometer events
80 You can enable / disable accelerometer events with this property.
81
82 Valid only on iOS. Not valid on Mac.
83
84 @since v0.8.1
85 */
86@property(nonatomic,assign) BOOL isAccelerometerEnabled;
87
88#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
89
90
91@interface CCLayer : CCNode <CCKeyboardEventDelegate, CCMouseEventDelegate, CCTouchEventDelegate>
92{
93 BOOL isMouseEnabled_;
94 BOOL isKeyboardEnabled_;
95 BOOL isTouchEnabled_;
96}
97
98/** whether or not it will receive mouse events.
99
100 Valind only Mac. Not valid on iOS
101 */
102@property (nonatomic, readwrite) BOOL isMouseEnabled;
103
104/** whether or not it will receive keyboard events.
105
106 Valind only Mac. Not valid on iOS
107 */
108@property (nonatomic, readwrite) BOOL isKeyboardEnabled;
109
110/** whether or not it will receive touch events.
111
112 Valid on iOS and Mac OS X v10.6 and later.
113 */
114@property (nonatomic, readwrite) BOOL isTouchEnabled;
115
116/** priority of the mouse event delegate.
117 Default 0.
118 Override this method to set another priority.
119
120 Valind only Mac. Not valid on iOS
121 */
122-(NSInteger) mouseDelegatePriority;
123
124/** priority of the keyboard event delegate.
125 Default 0.
126 Override this method to set another priority.
127
128 Valind only Mac. Not valid on iOS
129 */
130-(NSInteger) keyboardDelegatePriority;
131
132/** priority of the touch event delegate.
133 Default 0.
134 Override this method to set another priority.
135
136 Valind only Mac. Not valid on iOS
137 */
138-(NSInteger) touchDelegatePriority;
139
140#endif // mac
141
142
143@end
144
145#pragma mark -
146#pragma mark CCLayerColor
147
148/** CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
149
150 All features from CCLayer are valid, plus the following new features:
151 - opacity
152 - RGB colors
153 */
154@interface CCLayerColor : CCLayer <CCRGBAProtocol, CCBlendProtocol>
155{
156 GLubyte opacity_;
157 ccColor3B color_;
158 ccVertex2F squareVertices_[4];
159 ccColor4B squareColors_[4];
160
161 ccBlendFunc blendFunc_;
162}
163
164/** creates a CCLayer with color, width and height in Points*/
165+ (id) layerWithColor: (ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
166/** creates a CCLayer with color. Width and height are the window size. */
167+ (id) layerWithColor: (ccColor4B)color;
168
169/** initializes a CCLayer with color, width and height in Points */
170- (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
171/** initializes a CCLayer with color. Width and height are the window size. */
172- (id) initWithColor:(ccColor4B)color;
173
174/** change width in Points */
175-(void) changeWidth: (GLfloat)w;
176/** change height in Points */
177-(void) changeHeight: (GLfloat)h;
178/** change width and height in Points
179 @since v0.8
180 */
181-(void) changeWidth:(GLfloat)w height:(GLfloat)h;
182
183/** Opacity: conforms to CCRGBAProtocol protocol */
184@property (nonatomic,readonly) GLubyte opacity;
185/** Opacity: conforms to CCRGBAProtocol protocol */
186@property (nonatomic,readonly) ccColor3B color;
187/** BlendFunction. Conforms to CCBlendProtocol protocol */
188@property (nonatomic,readwrite) ccBlendFunc blendFunc;
189@end
190
191/** CCColorLayer
192 It is the same as CCLayerColor.
193
194 @deprecated Use CCLayerColor instead. This class will be removed in v1.0.1
195 */
196DEPRECATED_ATTRIBUTE @interface CCColorLayer : CCLayerColor
197@end
198
199#pragma mark -
200#pragma mark CCLayerGradient
201
202/** CCLayerGradient is a subclass of CCLayerColor that draws gradients across
203the background.
204
205 All features from CCLayerColor are valid, plus the following new features:
206 - direction
207 - final color
208 - interpolation mode
209
210 Color is interpolated between the startColor and endColor along the given
211 vector (starting at the origin, ending at the terminus). If no vector is
212 supplied, it defaults to (0, -1) -- a fade from top to bottom.
213
214 If 'compressedInterpolation' is disabled, you will not see either the start or end color for
215 non-cardinal vectors; a smooth gradient implying both end points will be still
216 be drawn, however.
217
218 If ' compressedInterpolation' is enabled (default mode) you will see both the start and end colors of the gradient.
219
220 @since v0.99.5
221 */
222@interface CCLayerGradient : CCLayerColor
223{
224 ccColor3B endColor_;
225 GLubyte startOpacity_;
226 GLubyte endOpacity_;
227 CGPoint vector_;
228 BOOL compressedInterpolation_;
229}
230
231/** Creates a full-screen CCLayer with a gradient between start and end. */
232+ (id) layerWithColor: (ccColor4B) start fadingTo: (ccColor4B) end;
233/** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. */
234+ (id) layerWithColor: (ccColor4B) start fadingTo: (ccColor4B) end alongVector: (CGPoint) v;
235
236/** Initializes the CCLayer with a gradient between start and end. */
237- (id) initWithColor: (ccColor4B) start fadingTo: (ccColor4B) end;
238/** Initializes the CCLayer with a gradient between start and end in the direction of v. */
239- (id) initWithColor: (ccColor4B) start fadingTo: (ccColor4B) end alongVector: (CGPoint) v;
240
241/** The starting color. */
242@property (nonatomic, readwrite) ccColor3B startColor;
243/** The ending color. */
244@property (nonatomic, readwrite) ccColor3B endColor;
245/** The starting opacity. */
246@property (nonatomic, readwrite) GLubyte startOpacity;
247/** The ending color. */
248@property (nonatomic, readwrite) GLubyte endOpacity;
249/** The vector along which to fade color. */
250@property (nonatomic, readwrite) CGPoint vector;
251/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
252 Default: YES
253 */
254@property (nonatomic, readwrite) BOOL compressedInterpolation;
255
256@end
257
258#pragma mark -
259#pragma mark CCLayerMultiplex
260
261/** CCLayerMultiplex is a CCLayer with the ability to multiplex it's children.
262 Features:
263 - It supports one or more children
264 - Only one children will be active a time
265 */
266@interface CCLayerMultiplex : CCLayer
267{
268 unsigned int enabledLayer_;
269 NSMutableArray *layers_;
270}
271
272/** creates a CCMultiplexLayer with one or more layers using a variable argument list. */
273+(id) layerWithLayers: (CCLayer*) layer, ... NS_REQUIRES_NIL_TERMINATION;
274/** initializes a MultiplexLayer with one or more layers using a variable argument list. */
275-(id) initWithLayers: (CCLayer*) layer vaList:(va_list) params;
276/** switches to a certain layer indexed by n.
277 The current (old) layer will be removed from it's parent with 'cleanup:YES'.
278 */
279-(void) switchTo: (unsigned int) n;
280/** release the current layer and switches to another layer indexed by n.
281 The current (old) layer will be removed from it's parent with 'cleanup:YES'.
282 */
283-(void) switchToAndReleaseMe: (unsigned int) n;
284@end
285
286/** CCMultiplexLayer
287 It is the same as CCLayerMultiplex.
288
289 @deprecated Use CCLayerMultiplex instead. This class will be removed in v1.0.1
290 */
291DEPRECATED_ATTRIBUTE @interface CCMultiplexLayer : CCLayerMultiplex
292@end
293