00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #import <OpenGLES/ES1/gl.h>
00028
00029 #import "CCAction.h"
00030 #import "ccTypes.h"
00031 #import "CCTexture2D.h"
00032 #import "CCProtocols.h"
00033 #import "ccConfig.h"
00034 #import "Support/CCArray.h"
00035
00036 enum {
00037 kCCNodeTagInvalid = -1,
00038 };
00039
00040 @class CCCamera;
00041 @class CCGridBase;
00042
00097 @interface CCNode : NSObject {
00098
00099
00100 float rotation_;
00101
00102
00103 float scaleX_, scaleY_;
00104
00105
00106 CGPoint position_;
00107
00108
00109 BOOL visible_;
00110
00111
00112 CGPoint anchorPointInPixels_;
00113
00114 CGPoint anchorPoint_;
00115
00116
00117
00118 BOOL isRelativeAnchorPoint_;
00119
00120
00121 CGSize contentSize_;
00122
00123
00124 CGAffineTransform transform_, inverse_;
00125 #if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
00126 GLfloat transformGL_[16];
00127 #endif
00128
00129
00130 float vertexZ_;
00131
00132
00133 CCCamera *camera_;
00134
00135
00136 CCGridBase *grid_;
00137
00138
00139 int zOrder_;
00140
00141
00142 CCArray *children_;
00143
00144
00145 CCNode *parent_;
00146
00147
00148 int tag_;
00149
00150
00151 void *userData;
00152
00153
00154 BOOL isRunning_;
00155
00156
00157 BOOL isTransformDirty_:1;
00158 BOOL isInverseDirty_:1;
00159 #if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
00160 BOOL isTransformGLDirty_:1;
00161 #endif
00162 }
00163
00165 @property(nonatomic,readonly) int zOrder;
00174 @property (nonatomic,readwrite) float vertexZ;
00176 @property(nonatomic,readwrite,assign) float rotation;
00178 @property(nonatomic,readwrite,assign) float scale;
00180 @property(nonatomic,readwrite,assign) float scaleX;
00182 @property(nonatomic,readwrite,assign) float scaleY;
00184 @property(nonatomic,readwrite,assign) CGPoint position;
00188 @property(nonatomic,readonly) CCArray *children;
00189
00190 @property(nonatomic,readonly) CCCamera* camera;
00192 @property(nonatomic,readwrite,retain) CCGridBase* grid;
00194 @property(nonatomic,readwrite,assign) BOOL visible;
00202 @property(nonatomic,readwrite) CGPoint anchorPoint;
00206 @property(nonatomic,readonly) CGPoint anchorPointInPixels;
00207
00213 @property (nonatomic,readwrite) CGSize contentSize;
00215 @property(nonatomic,readonly) BOOL isRunning;
00217 @property(nonatomic,readwrite,assign) CCNode* parent;
00222 @property(nonatomic,readwrite,assign) BOOL isRelativeAnchorPoint;
00224 @property(nonatomic,readwrite,assign) int tag;
00226 @property(nonatomic,readwrite,assign) void *userData;
00227
00228
00232 +(id) node;
00234 -(id) init;
00235
00236
00237
00238
00243 -(void) onEnter;
00248 -(void) onEnterTransitionDidFinish;
00253 -(void) onExit;
00254
00255
00256
00257
00262 -(id) addChild: (CCNode*)node;
00263
00268 -(id) addChild: (CCNode*)node z:(int)z;
00269
00274 -(id) addChild: (CCNode*)node z:(int)z tag:(int)tag;
00275
00276
00277
00282 -(void) removeFromParentAndCleanup:(BOOL)cleanup;
00283
00287 -(void) removeChild: (CCNode*)node cleanup:(BOOL)cleanup;
00288
00292 -(void) removeChildByTag:(int) tag cleanup:(BOOL)cleanup;
00293
00297 -(void) removeAllChildrenWithCleanup:(BOOL)cleanup;
00298
00299
00304 -(CCNode*) getChildByTag:(int) tag;
00305
00309 -(void) reorderChild:(CCNode*)child z:(int)zOrder;
00310
00314 -(void) cleanup;
00315
00316
00317
00329 -(void) draw;
00331 -(void) visit;
00332
00333
00334
00336 -(void) transform;
00337
00343 -(void) transformAncestors;
00344
00350 - (CGRect) boundingBox;
00351
00352
00353
00354
00361 -(CCAction*) runAction: (CCAction*) action;
00363 -(void) stopAllActions;
00365 -(void) stopAction: (CCAction*) action;
00369 -(void) stopActionByTag:(int) tag;
00374 -(CCAction*) getActionByTag:(int) tag;
00380 -(int) numberOfRunningActions;
00381
00382
00383
00385
00386
00393 -(void) scheduleUpdate;
00394
00401 -(void) scheduleUpdateWithPriority:(int)priority;
00402
00403
00404
00405
00406
00407 -(void) unscheduleUpdate;
00408
00409
00413 -(void) schedule: (SEL) s;
00420 -(void) schedule: (SEL) s interval:(ccTime)seconds;
00422 -(void) unschedule: (SEL) s;
00423
00428 -(void) unscheduleAllSelectors;
00429
00433 -(void) resumeSchedulerAndActions;
00437 -(void) pauseSchedulerAndActions;
00438
00439
00440
00444 - (CGAffineTransform)nodeToParentTransform;
00448 - (CGAffineTransform)parentToNodeTransform;
00452 - (CGAffineTransform)nodeToWorldTransform;
00456 - (CGAffineTransform)worldToNodeTransform;
00460 - (CGPoint)convertToNodeSpace:(CGPoint)worldPoint;
00464 - (CGPoint)convertToWorldSpace:(CGPoint)nodePoint;
00469 - (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint;
00474 - (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint;
00478 - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch;
00482 - (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch;
00483 @end