You can download cocos2d for iPhone v0.99.0-rc from here:
http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-0.99.0-rc.tar.gz
cocos2d v0.99.0-rc is SVN revision 1759
You can find the v0.99.0-rc documentation here:
To understand how fast cocos2d v0.99.0-rc is, please see the performance tests
Issue #712
cocos2d v0.99 is screen resolution independent. It means that it works with an screen resolution of 480×320 / 1024×768 or with any other screen resolution. It means it works with iPad.
Also it is possible to load textures of 2048×2048 in devices where it is supported (iPhone 3GS and probably the iPad).
Issue #520
v0.99 classes have the CC prefix. This prefix was added in order to prevent collision with other possible libraries or user code. So, it is safe to assume that:
CC belong to cocos2d.CC don't belong to cocos2dExample:
// v0.8.x classes Sprite *sprite = [Sprite sprite....]; Director *director = [Director sharedDirector]; Scene *scene = [Scene ...]; Layer *layer = [Layer ...]; // 0.99.0 classes CCSprite *sprite = [CCSprite sprite....]; CCDirector *director = [CCDirector sharedDirector]; CCScene *scene = [CCScene ...]; CCLayer *layer = [CCLayer ...];
There are some exceptions:
CocosNode class was renamed to CCNodeTextureMgr class was renamed to CCTextureCacheFor further info, please see: Migrating to v0.99
Issue #620
In v0.99 AtlasSprite and Sprite were merged in one single class: CCSprite.
New classes:
Sprite → CCSpriteAtlasSprite → CCSpriteAtlasSpriteFrame → CCSpriteFrameSpriteFrame → CCSpriteFrameAnimation → CCAnimationAtlasAnimation → CCAnimationAtlasSpriteManager → CCSpriteSheet ← NEW NAMEExample:
// v0.8 code: Atlas Sprites AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManager...]; AtlasSprite *sprite = [mgr createSpriteWith...]; [mgr addChild:sprite]; // v0.99 code CCSpriteSheet *sheet = [CCSpriteSheet spriteSheet...]; CCSprite *sprite = [CCSprite spriteWithSpriteSheet:sheet...]; [sheet addChild:sprite]; // v0.8 code: Sprites Sprite *sprite = [Sprite spriteWith...]; [self addChild:sprite]; // v0.99 code CCSprite *sprite = [CCSprite spriteWith...]; [self addChild:sprite];
As you can see, CCSprite can be used as a normal sprite or as a fast sprite when it is parented to an CCSpriteSheet.
But CCSpriteSheet has some limitations:
CCSprites as childrenCCSprites must have the same texture id as the CCSpriteSheetThe animation code in v0.99 was also merged:
v0.8 code:
Animation *sapusAnim = [Animation animationWithName:@"select" delay:0.3f images:@"SapusSelected1.png", @"SapusSelected2.png", @"SapusSelected1.png", @"SapusUnselected.png", nil];
v0.99 code:
CCAnimation *sapusAnim = [CCAnimation animationWithName:@"select" delay:0.3f]; [sapusAnim addFrameWithFilename:@"SapusSelected1.png"]; [sapusAnim addFrameWithFilename:@"SapusSelected2.png"]; [sapusAnim addFrameWithFilename:@"SapusSelected1.png"]; [sapusAnim addFrameWithFilename:@"SapusUnselected.png"];
v0.8 code:
AtlasAnimation *animFly = [AtlasAnimation animationWithName:@"fly" delay:0.2f]; [animFly addFrameWithRect: CGRectMake(64*0, 64*0, 64, 64)]; [animFly addFrameWithRect: CGRectMake(64*1, 64*0, 64, 64)]; [animFly addFrameWithRect: CGRectMake(64*2, 64*0, 64, 64)];
v0.99 code:
CCAnimation *animFly = [CCAnimation animationWithName:@"fly" delay:0.2f]; [animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*0, 64*0, 64, 64)]; [animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*1, 64*0, 64, 64)]; [animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*2, 64*0, 64, 64)];
One of the benefits of v0.99 is the CCSpriteFrameCache class, since it lets you write animation code more easily.
CCSpriteFrameCache is an sprite frame cache. Basically you can add frames to this cache, and you can get them by name. You can easily create an animation using the frame cache.
CCSpriteFrameCache supports the Zwoptex format. The zwoptex format is easy to parse and use. In case you decide not to use use, you can also add sprite frames to the cache by adding them manually, or by adding them with an NSDictionary.
eg:
// loads the sprite frames from a Zwoptex generated file [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"animations/grossini.plist"]; NSMutableArray *animFrames = [NSMutableArray array]; for(int i = 0; i < 14; i++) { CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"grossini_dance_%02d.png",(i+1)]]; [animFrames addObject:frame]; } CCAnimation *animation = [CCAnimation animationWithName:@"dance" delay:0.2f frames:animFrames];
For further info, please see: Migrating to v0.99
// Create an SpriteSheet CCSpriteSheet *sheet = [CCSpriteSheet spriteSheetWithFile:@"animations/grossini.png" capacity:50]; // Add sprite sheet to parent [self addChild:sheet]; // Load sprite frames [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"animations/grossini.plist"]; CCSprite *sprite1 = [CCSprite spriteWithSpriteFrameName:@"grossini_dance_01.png"]; [sprite1 setPosition:ccp( s.width/3, s.height/2)]; CCSprite *sprite2 = [CCSprite spriteWithFrameFrameName:@"grossini_dance_02.png"]; [sprite2 setPosition:ccp(50,50)]; CCSprite *sprite3 = [CCSprite spriteWithSpriteFrameName:@"grossini_dance_03.png"]; [sprite3 setPosition:ccp(-50,-50)]; [sheet addChild:sprite1]; // NEW NEW NEW // sprite1 supports children [sprite1 addChild:sprite2]; [sprite1 addChild:sprite3];
Full example:
Issue #643
Suppose that you want to create a health bar on top of your sprite. The easiest way to do it is by adding the health bar as a child of your sprite.
This works as expected expect if you sprite rotates, since the health bar will rotate too.
To prevent this behavior the CCSprite object has a new property: honorParentTransform.
By default the child (in our example, the “health bar”) will rotate, translate and scale relative to it's parent. But we can override this behavior by:
// default value healthBar.honorParentTransform = CC_HONOR_PARENT_TRANSFORM_ALL; // ignores parent rotation healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_ROTATE; // ignores parent scale healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_SCALE; // ignores parent scale healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_TRANSLATE;
Full example:
Issue #627
The CCAnimate action now supports reverse.
Example:
id action = [CCAnimate actionWithAnimation: animation restoreOriginalFrame:NO]; id action_back = [action reverse]; [sprite runAction: [CCSequence actions: action, action_back, nil]];
Since part of issue #620 was rollbacked, these 2 Instant Actions where added.
Example:
CCSequence *seq = [CCSequence actions: animate, [CCFlipX actionWithFlipX:YES], [[animate copy] autorelease], [CCFlipX actionWithFlipX:NO], nil]; [sprite runAction:[CCRepeatForever actionWithAction: seq ]];
Issue #390
CCRepeat and CCRepeatForever repeat the action without jerking. The repetitions are smooth now.
Issue #705
CCRotateTo works as expected when it is part of a CCRepeat action.Issue #XXX
CCSequence performance was improved between 30~50%. Instead of using an NSArray is uses a C array.CCBitmapFontAtlas works with subdirectories.setString doesn't override colorExample:
// subdirectory CCBitmapFontAtlas *label1 = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Test" fntFile:@"fonts/bitmapFontTest2.fnt"]; [self addChild:label1]; // color [label1 setColor:ccRED]; [label1 setString:@"This is a red string"];
Example:
b2BodyDef bd; bd.type = b2DynamicBody; // default type is static body
The camera object that belongs to CCNode was rewritten. And it is not 100% compatible with the old camera.
New features:
Limitations:
For further information, please read: Discussion about the new camera implementation and its workaround
Issue #664
Issue #597
CCColorLayer supports the CCBlendProtocol. You can create “negative” images with it.Full example:
Issues #718
To improve the CCNode / CCSprite performance these changes were made:
glTranslate, glScale and glRotate calls. Instead a glMulMatrix is executed.glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D);
So, for example if your node only needs GL_TEXTURE_2D, you should do:
-(void) draw { // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // Needed states: GL_TEXTURE_2D, // Unneeded states: GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); [...] draw your stuff. // restore GL default states glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); }
For further information, please read this thread: http://www.cocos2d-iphone.org/forum/topic/3976
Issues #657
The only class that knows how to create sprites is CCSprite.
The creation methods from CCSpriteSheet and CCSpriteFrameCache were removed.
The benefits of this change, is that it is easier to create a subclass of CCSprite.
if you want to create an CCSprite subclass, you don't need to implement each of the initWithXXX method. You are safe by just implementing init:
Example:
@implementation MySprite -(id) init { if( (self=[super init]) ) { ivar1 = xxx; ivar2 = yyy; ivar3 = zzz; } return self; } @end // And to create an instance of MySprite you simply do: MySprite *sprite = [MySprite spriteWithFile...]; // or MySprite *sprite = [MySprite spriteWithSpriteSheet:....]; // or any of the supported CCSprite methods.
// mipmaps CCTexture2D *texture0 = [[CCTextureCache sharedTextureCache] addImage:@"grossini_dance_atlas.png"]; // generate mipmap textures [texture0 generateMipmap]; // update the tex parameters so MIPMAP_LINEAR is used ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; [texture0 setTexParameters:&texParams];
Full example:
Issue #581
The CCTextureAtlas object (used by CCSpriteSheet) uses by default VBO instead of vertex array list.
CCTMXTiledMap works with subdirectories.Example:
// subdirectory example CCTMXTiledMap *map = [CCTMXTiledMap tiledMapWithTMXFile:@"TileMaps/orthogonal-test4.tmx"]; [self addChild:map z:0 tag:kTagTileMap];
Issue #710
The TouchDispatcher suffered a smal refactor. New features:
void and not BOOL// v0.8 code - (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // do something return kEventHandled; } // v0.99 code - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // do something }
For further information about the implementation of this feature, please read: http://www.cocos2d-iphone.org/forum/topic/3853#post-23061
Issue #646
CCCrossFadeTransition. It fades in the incoming scene while the outgoing scene fades out.Full example:
Please see the Migrating to v0.99 wiki page.
All deprecated classes/methods in v0.8.x were removed from v0.99
Issue #620
MenuItemAtlasSprite was removed because:
CCSprites supports rectsMenuItemAtlasSprite was a hack. You needed to add the items in 2 different places and it wasn't obvious at allMenuItemAtlasSprite and MenuItemSprite should be more or less equal
Since CCTextureNode was superseded by CCSprite, CCTextureNode was removed.
Steps to use the v0.99 cocos2d files:
Full changelog: CHANGELOG
version 0.99.0-rc - 31-Jan-2010
version 0.9.0-beta - 11-Jan-2010
version 0.9.0-beta - 14-Dic-2009
version 0.9.0-alpha - 18-Nov-2009