/libs/cocos2d/CCLayer.h
C Header | 144 lines | 42 code | 16 blank | 86 comment | 0 complexity | 0c930d8c2fc989a06acea6eb10501784 MD5 | raw file
Possible License(s): Apache-2.0
1/* 2 * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 * 4 * Copyright (c) 2008-2010 Ricardo Quesada 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 * 24 */ 25 26 27 28#import <UIKit/UIKit.h> 29 30#import "CCProtocols.h" 31#import "CCNode.h" 32#import "CCTouchDelegateProtocol.h" 33 34// 35// CCLayer 36// 37/** CCLayer is a subclass of CCNode that implements the TouchEventsDelegate protocol. 38 39 All features from CCNode are valid, plus the following new features: 40 - It can receive iPhone Touches 41 - It can receive Accelerometer input 42*/ 43@interface CCLayer : CCNode <UIAccelerometerDelegate, CCStandardTouchDelegate, CCTargetedTouchDelegate> 44{ 45 BOOL isTouchEnabled; 46 BOOL isAccelerometerEnabled; 47} 48 49/** If isTouchEnabled, this method is called onEnter. Override it to change the 50 way CCLayer receives touch events. 51 ( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] ) 52 Example: 53 -(void) registerWithTouchDispatcher 54 { 55 [[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES]; 56 } 57 @since v0.8.0 58 */ 59-(void) registerWithTouchDispatcher; 60 61/** whether or not it will receive Touch events. 62 You can enable / disable touch events with this property. 63 Only the touches of this node will be affected. This "method" is not propagated to it's children. 64 @since v0.8.1 65 */ 66@property(nonatomic,assign) BOOL isTouchEnabled; 67/** whether or not it will receive Accelerometer events 68 You can enable / disable accelerometer events with this property. 69 @since v0.8.1 70 */ 71@property(nonatomic,assign) BOOL isAccelerometerEnabled; 72 73@end 74 75// 76// CCColorLayer 77// 78/** CCColorLayer is a subclass of CCLayer that implements the CCRGBAProtocol protocol. 79 80 All features from CCLayer are valid, plus the following new features: 81 - opacity 82 - RGB colors 83 */ 84@interface CCColorLayer : CCLayer <CCRGBAProtocol, CCBlendProtocol> 85{ 86 GLubyte opacity_; 87 ccColor3B color_; 88 GLfloat squareVertices[4 * 2]; 89 GLubyte squareColors[4 * 4]; 90 91 ccBlendFunc blendFunc_; 92} 93 94/** creates a CCLayer with color, width and height */ 95+ (id) layerWithColor: (ccColor4B)color width:(GLfloat)w height:(GLfloat)h; 96/** creates a CCLayer with color. Width and height are the window size. */ 97+ (id) layerWithColor: (ccColor4B)color; 98 99/** initializes a CCLayer with color, width and height */ 100- (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat)h; 101/** initializes a CCLayer with color. Width and height are the window size. */ 102- (id) initWithColor:(ccColor4B)color; 103 104/** change width */ 105-(void) changeWidth: (GLfloat)w; 106/** change height */ 107-(void) changeHeight: (GLfloat)h; 108/** change width and height 109 @since v0.8 110 */ 111-(void) changeWidth:(GLfloat)w height:(GLfloat)h; 112 113/** Opacity: conforms to CCRGBAProtocol protocol */ 114@property (nonatomic,readonly) GLubyte opacity; 115/** Opacity: conforms to CCRGBAProtocol protocol */ 116@property (nonatomic,readonly) ccColor3B color; 117/** BlendFunction. Conforms to CCBlendProtocol protocol */ 118@property (nonatomic,readwrite) ccBlendFunc blendFunc; 119@end 120 121/** CCMultipleLayer is a CCLayer with the ability to multiplex it's children. 122 Features: 123 - It supports one or more children 124 - Only one children will be active a time 125 */ 126@interface CCMultiplexLayer : CCLayer 127{ 128 unsigned int enabledLayer; 129 NSMutableArray *layers; 130} 131 132/** creates a CCMultiplexLayer with one or more layers using a variable argument list. */ 133+(id) layerWithLayers: (CCLayer*) layer, ... NS_REQUIRES_NIL_TERMINATION; 134/** initializes a MultiplexLayer with one or more layers using a variable argument list. */ 135-(id) initWithLayers: (CCLayer*) layer vaList:(va_list) params; 136/** switches to a certain layer indexed by n. 137 The current (old) layer will be removed from it's parent with 'cleanup:YES'. 138 */ 139-(void) switchTo: (unsigned int) n; 140/** release the current layer and switches to another layer indexed by n. 141 The current (old) layer will be removed from it's parent with 'cleanup:YES'. 142 */ 143-(void) switchToAndReleaseMe: (unsigned int) n; 144@end