/
Layer.h
112 lines (95 loc) · 3.26 KB
/
Layer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* cocos2d for iPhone
*
* http://www.cocos2d-iphone.org
*
* Copyright (C) 2008,2009 Ricardo Quesada
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the 'cocos2d for iPhone' license.
*
* You will find a copy of this license within the cocos2d for iPhone
* distribution inside the "LICENSE" file.
*
*/
#import <UIKit/UIKit.h>
#import "CocosNode.h"
#import "TouchDelegateProtocol.h"
//
// Layer
//
/** Layer is a subclass of CocosNode that implements the TouchEventsDelegate protocol.
All features from CocosNode are valid, plus the following new features:
- It can receive iPhone Touches
- It can receive Accelerometer input
*/
@interface Layer : CocosNode <UIAccelerometerDelegate, StandardTouchDelegate, TargetedTouchDelegate>
{
BOOL isTouchEnabled;
BOOL isAccelerometerEnabled;
}
/** If isTouchEnabled, this method is called onEnter. Override it to change the
way Layer receives touch events.
( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] )
Example:
-(void) registerWithTouchDispatcher
{
[[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES];
}
*/
-(void) registerWithTouchDispatcher;
// whether or not it will receive Touch events
@property(nonatomic,assign) BOOL isTouchEnabled;
// whether or not it will receive Accelerometer events
@property(nonatomic,assign) BOOL isAccelerometerEnabled;
@end
//
// ColorLayer
//
/** ColorLayer is a subclass of Layer that implements the CocosNodeRGBA protocol.
All features from Layer are valid, plus the following new features:
- opacity
- RGB colors
*/
@interface ColorLayer : Layer <CocosNodeRGBA>
{
GLubyte opacity_;
ccColor3B color_;
GLfloat squareVertices[4 * 2];
GLubyte squareColors[4 * 4];
}
/** creates the Layer with color, width and height */
+ (id) layerWithColor: (ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
/** creates the layer with color. Width and height are the window size. */
+ (id) layerWithColor: (ccColor4B)color;
/** initializes a Layer with color, width and height */
- (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
/** initializes a Layer with color. Width and height are the window size. */
- (id) initWithColor:(ccColor4B)color;
/** change width */
-(void) changeWidth: (GLfloat)w;
/** change height */
-(void) changeHeight: (GLfloat)h;
/** change width and height
@since v0.8
*/
-(void) changeWidth:(GLfloat)w height:(GLfloat)h;
/** Opacity: conforms to CocosNodeRGBA protocol */
@property (readonly) GLubyte opacity;
/** Opacity: conforms to CocosNodeRGBA protocol */
@property (readonly) ccColor3B color;
@end
/** A Layer with the ability to multiplex it's children */
@interface MultiplexLayer : Layer
{
unsigned int enabledLayer;
NSMutableArray *layers;
}
/** creates a MultiplexLayer with one or more layers */
+(id) layerWithLayers: (Layer*) layer, ... NS_REQUIRES_NIL_TERMINATION;
/** initializes a MultiplexLayer with one or more layers */
-(id) initWithLayers: (Layer*) layer vaList:(va_list) params;
/** switches to a certain layer indexed by n*/
-(void) switchTo: (unsigned int) n;
/** release the current layer and switches to another layer indexed by n */
-(void) switchToAndReleaseMe: (unsigned int) n;
@end