You can download cocos2d for iPhone v0.9.0-beta from here:
http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-0.9.0-beta.tar.gz
cocos2d v0.9.0-beta is SVN revision 1618
You can find the v0.9.0-beta documentation here:
To understand how fast cocos2d v0.9.0-beta is, please see the performance tests:
Issue #520
v0.9 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.9.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.9
Issue #620
In v0.9 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.9 code CCSpriteSheet *sheet = [CCSpriteSheet spriteSheet...]; CCSprite *sprite = [sheet createSpriteWith...]; [sheet addChild:sprite]; // v0.8 code: Sprites Sprite *sprite = [Sprite spriteWith...]; [self addChild:sprite]; // v0.9 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.9 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.9 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.9 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.9 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.9
// 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 = [[CCSpriteFrameCache sharedSpriteFrameCache] createSpriteWithFrameName:@"grossini_dance_01.png"]; [sprite1 setPosition:ccp( s.width/3, s.height/2)]; CCSprite *sprite2 = [[CCSpriteFrameCache sharedSpriteFrameCache] createSpriteWithFrameName:@"grossini_dance_02.png"]; [sprite2 setPosition:ccp(50,50)]; CCSprite *sprite3 = [[CCSpriteFrameCache sharedSpriteFrameCache] createSpriteWithFrameName:@"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]];
Issue #612
CCBitmapFontAtlas works with subdirectories.
Example:
CCBitmapFontAtlas *label1 = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Test" fntFile:@"fonts/bitmapFontTest2.fnt"]; [self addChild:label1];
Issue #494
Box2d was updated to r31. Since r31 you should specify body type. Example:
b2BodyDef bd; bd.type = b2DynamicBody; // default type is static body
Issue #664
Issue #597
CCColorLayer supports the CCBlendProtocol. You can create “negative” images with it.Full example:
Issue #632
. It's possible to generate mipmap textures in runtime
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.
Issue #539
CCTMXTiledMap works with subdirectories.
Example:
CCTMXTiledMap *map = [CCTMXTiledMap tiledMapWithTMXFile:@"TileMaps/orthogonal-test4.tmx"]; [self addChild:map z:0 tag:kTagTileMap];
Issue #646
CCCrossFadeTransition. It fades in the incoming scene while the outgoing scene fades out.Full example:
Please see the Migrating to v0.9 wiki page.
All deprecated classes/methods in v0.8.x were removed from v0.9
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 equalSteps to use the v0.9 cocos2d files:
Full changelog: CHANGELOG
version 0.9.0-beta - 14-Dic-2009
version 0.9.0-alpha - 18-Nov-2009