![]() |
cocos2d-iphone
2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
|
Defines | |
#define | __CC_PLATFORM_IOS 1 |
#define | __CCLOGWITHFUNCTION(s,...) NSLog(@"%s : %@",__FUNCTION__,[NSString stringWithFormat:(s), ##__VA_ARGS__]) |
#define | __CCLOG(s,...) NSLog(@"%@",[NSString stringWithFormat:(s), ##__VA_ARGS__]) |
#define | CCLOG(...) do {} while (0) |
#define | CCLOGWARN(...) do {} while (0) |
#define | CCLOGINFO(...) do {} while (0) |
#define | CC_SWAP(x, y) |
#define | CCRANDOM_MINUS1_1() ((random() / (float)0x3fffffff )-1.0f) |
#define | CCRANDOM_0_1() ((random() / (float)0x7fffffff )) |
#define | CC_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f) |
#define | CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) |
#define | kCCRepeatForever (UINT_MAX -1) |
#define | CC_BLEND_SRC GL_ONE |
#define | CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA |
#define | CC_DIRECTOR_INIT() |
#define | CC_NODE_DRAW_SETUP() |
#define | CC_DIRECTOR_END() |
#define | CC_CONTENT_SCALE_FACTOR() __ccContentScaleFactor |
#define | CC_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) |
#define | CC_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) |
#define | CC_POINT_PIXELS_TO_POINTS(__pixels__) CGPointMake( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR()) |
#define | CC_POINT_POINTS_TO_PIXELS(__points__) CGPointMake( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR()) |
#define | CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) CGSizeMake( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR()) |
#define | CC_SIZE_POINTS_TO_PIXELS(__size_in_points__) CGSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR()) |
#define | CC_PROFILER_DISPLAY_TIMERS() do {} while (0) |
#define | CC_PROFILER_PURGE_ALL() do {} while (0) |
#define | CC_PROFILER_START(__name__) do {} while (0) |
#define | CC_PROFILER_STOP(__name__) do {} while (0) |
#define | CC_PROFILER_RESET(__name__) do {} while (0) |
#define | CC_PROFILER_START_CATEGORY(__cat__, __name__) do {} while(0) |
#define | CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do {} while(0) |
#define | CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do {} while(0) |
#define | CC_PROFILER_START_INSTANCE(__id__, __name__) do {} while(0) |
#define | CC_PROFILER_STOP_INSTANCE(__id__, __name__) do {} while(0) |
#define | CC_PROFILER_RESET_INSTANCE(__id__, __name__) do {} while(0) |
#define | CC_ARC_RETAIN(value) [value retain] |
#define | CC_ARC_RELEASE(value) [value release] |
#define | CC_ARC_UNSAFE_RETAINED |
#define | CC_INCREMENT_GL_DRAWS(__n__) __ccNumberOfDraws += __n__ |
#define | CCAnimationFrameDisplayedNotification @"CCAnimationFrameDisplayedNotification" |
Variables | |
float | __ccContentScaleFactor |
NSUInteger | __ccNumberOfDraws |
cocos2d helper macros
#define CC_ARC_RETAIN | ( | value | ) | [value retain] |
ARC Macros
#define CC_BLEND_SRC GL_ONE |
default gl blend src function. Compatible with premultiplied alpha images.
#define CC_CONTENT_SCALE_FACTOR | ( | ) | __ccContentScaleFactor |
RETINA DISPLAY ENABLED On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
#define CC_DEGREES_TO_RADIANS | ( | __ANGLE__ | ) | ((__ANGLE__) * 0.01745329252f) |
converts degrees to radians
#define CC_DIRECTOR_END | ( | ) |
do { \ CCDirector *__director = [CCDirector sharedDirector]; \ [__director end]; \ } while(0)
Stops and removes the director from memory. Removes the CCGLView from its parent
#define CC_DIRECTOR_INIT | ( | ) |
do { \ window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; \ director_ = (CCDirectorIOS*)[CCDirector sharedDirector]; \ [director_ setDisplayStats:NO]; \ [director_ setAnimationInterval:1.0/60]; \ CCGLView *__glView = [CCGLView viewWithFrame:[window_ bounds] \ pixelFormat:kEAGLColorFormatRGB565 \ depthFormat:0 /* GL_DEPTH_COMPONENT24_OES */ \ preserveBackbuffer:NO \ sharegroup:nil \ multiSampling:NO \ numberOfSamples:0 \ ]; \ [director_ setView:__glView]; \ [director_ setDelegate:self]; \ director_.wantsFullScreenLayout = YES; \ if( ! [director_ enableRetinaDisplay:YES] ) \ CCLOG(@"Retina Display Not supported"); \ navController_ = [[UINavigationController alloc] initWithRootViewController:director_]; \ navController_.navigationBarHidden = YES; \ [window_ addSubview:navController_.view]; \ [window_ makeKeyAndVisible]; \ } while(0)
IMPORTANT: If you want to use another type of render buffer (eg: RGBA8) or if you want to use a 16-bit or 24-bit depth buffer, you should NOT use this macro. Instead, you should create the CCGLView manually.
#define CC_INCREMENT_GL_DRAWS | ( | __n__ | ) | __ccNumberOfDraws += __n__ |
Increments the GL Draws counts by one. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.
#define CC_NODE_DRAW_SETUP | ( | ) |
do { \ ccGLEnable( _glServerState ); \ NSAssert1(_shaderProgram, @"No shader program set for node: %@", self); \ [_shaderProgram use]; \ [_shaderProgram setUniformsForBuiltins]; \ } while(0)
Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
#define CC_POINT_PIXELS_TO_POINTS | ( | __pixels__ | ) | CGPointMake( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR()) |
Converts a rect in pixels to points
#define CC_POINT_POINTS_TO_PIXELS | ( | __points__ | ) | CGPointMake( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR()) |
Converts a rect in points to pixels
#define CC_PROFILER_DISPLAY_TIMERS | ( | ) | do {} while (0) |
Profiling Macros
#define CC_RADIANS_TO_DEGREES | ( | __ANGLE__ | ) | ((__ANGLE__) * 57.29577951f) |
converts radians to degrees
#define CC_RECT_PIXELS_TO_POINTS | ( | __rect_in_pixels__ | ) |
CGRectMake( (__rect_in_pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).size.height / CC_CONTENT_SCALE_FACTOR() )
Converts a rect in pixels to points
#define CC_RECT_POINTS_TO_PIXELS | ( | __rect_in_points_points__ | ) |
CGRectMake( (__rect_in_points_points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_points_points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).size.height * CC_CONTENT_SCALE_FACTOR() )
Converts a rect in points to pixels
#define CC_SWAP | ( | x, | |
y | |||
) |
({ __typeof__(x) temp = (x); \ x = y; y = temp; \ })
simple macro that swaps 2 variables
#define CCAnimationFrameDisplayedNotification @"CCAnimationFrameDisplayedNotification" |
Notifications Notification name when a CCSpriteFrame is displayed
#define CCRANDOM_0_1 | ( | ) | ((random() / (float)0x7fffffff )) |
returns a random float between 0 and 1
#define CCRANDOM_MINUS1_1 | ( | ) | ((random() / (float)0x3fffffff )-1.0f) |
returns a random float between -1 and 1