Friday, 9 December 2011

New way to declare private methods

Normally I would put private methods in the header file. But noticed from "Learn Cocos2D 2nd Edition" book a different way been used.

The header file is quite simple:

#import "cocos2d.h"

@interface HelloWorld : CCLayer

// returns a Scene that contains the HelloWorld as the only child
+(id) scene;


The private methods are however declared in the .m file as shown below with "(PrivateMethods)" added behind "@interface":

#import "HelloWorldScene.h"

// private methods are declared in this manner to avoid "may not respond to ..." compiler warnings
@interface HelloWorld (PrivateMethods)
-(void) onCallFunc;
-(void) onCallFuncN:(id)sender;
-(void) onCallFuncND:(id)sender data:(void*)data;
-(void) onCallFuncO:(id)object;
-(void) createLabelWithOffset:(int)offset;

@implementation HelloWorld

This is completely new to me and indeed quite interesting!

Sunday, 4 December 2011

ARM CPUs of the iOS devices don't support division operations in hardware?

Read in the "Learn Cocos2D 2nd Edition" book Chapter 4 that "since the ARM CPUs of the iOS devices don't support division operations in hardware, multiplications are generally a bit faster."

So instead of divide by 2, you should use multiple by 0.5 - this is interesting...

uDevGames 2011 result published

In case you are not aware, the result of uDevGames 2011 is available here. Although most of the games are for Mac OS X, you should be able to learn something there, as most importantly - there's quite of few of them with both source code and binary available for download!