Published on
March 20, 2009 in
cocos2d.
Hey,
cocos2d v0.7.1 is available for download.
Download:
http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-0.7.1.tar.gz
Highlights:
- Sprite Sheets (For further info please read this post: spritesheet-in-v071 )
- Local to World coordinates and vice-versa
- Sound Support (warning: experimental feature)
Compatibility:
cocos2d v0.7.1 is 90% compatible with v0.7.0. You need to add new files and
you might need to add some linker parameter. Also some selectors were deprecated.
Please, read CAREFULLY the following instructions:
Full Changelog:
- Actions: added tags to actions (issue #222)
- Actions: Spawns can be Speeded (issue #257)
- Actions: Speed can be altered in runtime (part of issue #236)
- AtlasSprite: Sprite sheet implementation (issue #238)
- Chipmunk: cpVect is defined as a CGPoint (issue #260)
- CocosNode: Camera is lazy alloced (issue #94)
- CocosNode: addChild, removeChild:cleanup, getChildByTag family functions (issue #253)
- CocosNode: added better comments, cleanup code (issue #219)
- CocosNode: added RGB protocol: Atlas,Texture & ColorLayer conforms it (issue #234)
- CocosNode: fixed memory leak when removeAndStop a node with children with actions (issue #254)
- CocosNode: added transform local to world coordinates that support rotation,scale & position (issue #207)
- CocosNode: removed scale ivar (issue #231)
- CocosNode: improved handling of nil parameters (issue #262)
- CocosLive: filter by device id (issue #223)
- CocosLive: category is UTF8′ized (issue #227)
- CocosLive: using cc_playername instead of usr_playername (issue #242)
- CocosLive: supports “update score” (issue #250)
- Demos: added performance test (issue #243)
- Director: FastDirector doesn’t leak autoreleased objects (issue #221)
- Director: prevents calling startAnimation twice in a row (issue #215)
- Menu: can be aligned in columns / rows. Updated menu example (issue #206)
- Menu: MenuItem supports LabelAtlas (issue #235)
- Menu: MenuItemFont fixed memory leak (issue #232)
- Menu: MenuItem improved hit testing (issue #214)
- Scheduler: if signature is not correct Assert (issue #218)
- Sprite: correct transform anchor point (issue #216)
- TextureAtlas: support for texture2D (issue #161)
- Tools: Added perf-test results (issue #243)
As always, big thanks to the community for adding new features, fixing bugs, submitting patches, opening issues, testing the release candidate, etc!!
Sapus Tongue v1.6 source code released.
Changes:
- Uses cocos2d v0.7.1 RC (revision 702)
- Sapus Tongue code is using the new API from cocos2d v0.7.1
- Executables has NSDebugEnabled, NSZombieEnabled, NSAutoreleaseFreedObjectCheckEnabled environment variables. These variable are useful to find “double free” bugs.
- Added -ObjC parameter in linker options. This option lets you link class extensions from a static library. Needed to link CocosNode(CocosNodeExtras) (new in cocos2d v0.7.1)
- Uses sprite sheets (new feature from cocos2d v0.7.1)
- sprite-sheet-ufo.png (instead of 3 different sprites)
- sprite-sheet-monus.png (instead of 10 different sprites)
- sprite-sheet-sapus.png (instead of 5 different sprites)
- TouchJSON is a static lib. SapusTongueLite doesn’t need it since TouchJSON it is part of AdMoblib too. Since SapusTongue (non-lite) uses it.
Sapus Tongue and Sapus Tongue Lite v1.6 are in review in the App Store. Hopefully they will available for download in 3 or 4 days.
If you have bought the Premium or Updates source code package, you should have received an email with the download link. If you have not yet received it, please let me know and I’ll be happy to send it to you. Thanks.
Published on
March 13, 2009 in
cocos2d.
Chipmunk has a type called cpVect that is used to define a vector.
The above mentioned structure is defined as:
typedef struct cpVect{ cpFloat x,y;} cpVect;
On the other hand, CoreGraphics has a similar type called CGPoint that is defined as:
struct CGPoint {CGFloat x;CGFloat y;};typedef struct CGPoint CGPoint;
These 2 types has the same attributes (they are identical) but they aren’t interchangeable because they are different types.
You can’t do add a CGPoint with a cpVect, neither you can’t test whether or not a cpVect is inside a CGRect, etc.
Since cocos2d v0.7.1 you will be able to mix them and use them interchangeably. The solution was a simple hack:
// file cpVect.h
#import <CoreGraphics/CGGeometry.h>#define cpVect CGPoint//typedef struct cpVect{// cpFloat x,y;//} cpVect;
Published on
March 11, 2009 in
cocos2d.

Perhaps the most important feature that is missing in cocos2d for iPhone is a Programing Guide. In the meantime you can learn cocos2d for iPhone by:
You can also read news and some recipes from these blogs:
And if you have a question and you don’t know who to ask, you can ask it in the cocos2d forum:
Ah… and last but not least, if you are also new to iPhone and objective-c, check this page:
Published on
March 11, 2009 in
cocos2d.

cocos2d v0.7.1 supports SpriteSheets. An SpriteSheet basically is an image that contains subimages, and these subimages can be used as sprites. In cocos2d v0.7.1 these new sprites are called AtlasSprite.
These are the benefits of using AtlasSprite instead of the normal Sprite:
- Reduces texture memory since all the sprites are in one big image.
- Reduces render time since there are less OpenGL calls. The new order is O(1) while the order of using normal Sprites is O(n). If you have 400 AtlasSprites, now you have to do 6 OpenGL calls. With 400 Sprites you have to do 400 *6 OpenGL calls.
How do you use it?:
// Create the AtlasSpriteManager
// You can use a .PNG file or a PVRTC image.
// capacity is an optional parameter. It is just a hint that means the quantity of total sprites.
// You can add more (or less) sprites than the quantity.
// grossini_dance_atlas.png is an image than contains the subsprites.
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
// You create the sprite
AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
// you add the sprite to the parent
// the parent must be the AtlasSpriteManager
// z must be 0.
// You can add tags if you want.
[mgr addChild:sprite z:0 tag:kTagSprite1];
// you can transform the sprite
sprite.position = cpv( 200,300 );
sprite.rotation = 90;
sprite.scale = 2.0f;
// you can run actions in this new sprite
[sprite runAction: [RotateBy actionWithDuration:2 angle:360]];
The TestAtlas.m file (Example #5) contains a working example of AtlasSprite.
The PerformanceTest example compares Sprite vs AtlasSprite performance (more on this later).
Published on
March 11, 2009 in
cocos2d.

cocos2d-iphone started as a port of cocos2d-python and during the port most of the function names remained exactly the same. For example, in cocos2d-python to add child to a parent you should do this:
parent.add( child )
and in cocos2d-iphone you should do this:
[parent add:child];
But the name add does not follow the objective-c convention. So, in v0.7.1 these functions will be deprecated. This means that these functions will be still present during the v0.7 series. A warning will be displayed at compile time and at runtime (in debug mode only) but they will still work as expected.
In v0.8 these functions will be removed.
These are the new functions:
Add:
[self add:node]; // OLD[self addChild:node]; // NEW
[self add:node z:0]; // OLD[self addChild:node z:0]; // NEW
[self add:node z:0 tag:t]; // OLD[self addChild:node z:0 tag:t]; // NEW
[self add:node z:0 tag:t parallaxRatio]; // OLD[self addChild:node z:0 tag:t parallaxRatio]; // NEW
Get:
[self getByTag:tag]; // OLD[self getChildByTag:tag]; // NEW
Remove:
[self remove:node]; // OLD[self removeChild:node cleanup:NO]; // NEW
[self removeAndStop:node]; // OLD[self removeChild:node cleanup:YES]; // NEW
[self removeByTag:tag]; // OLD[self removeChildByTag:tag cleanup:NO]; // NEW
[self removeAndStopByTag:tag]; // OLD[self removeChildByTag:tag cleanup:YES]; // NEW
[self removeAll]; // OLD[self removeAllChildrenWithCleanup: NO]; // NEW
[self removeAndStopAll]; // OLD[self removeAllChildrenWithCleanup: YES]; // NEW
Actions:
[self do: action]; // OLD[self runAction: action]; // NEW
It is noteworthy the new cleanup parameter. If you want to stop all running actions and/or scheduled functions in a node, use the cleanup parameter with YES.
Published on
March 11, 2009 in
cocos2d.

cocos2d v0.7.1 supports SpriteSheets. An SpriteSheet basically is an image that contains subimages, and these subimages can be used as sprites. In cocos2d v0.7.1 these new sprites are called AtlasSprite.
These are the benefits of using AtlasSprite instead of the normal Sprite:
- Reduces texture memory since all the sprites are in one big image.
- Reduces render time since there are less OpenGL calls. The new order is O(1) while the order of using normal Sprites is O(n). If you have 400 AtlasSprites, now you have to do 6 OpenGL calls. With 400 Sprites you have to do 400 *6 OpenGL calls.
How do you use it?:
// Create the AtlasSpriteManager// You can use a .PNG file or a PVRTC image.// capacity is an optional parameter. It is just a hint that means the quantity of total sprites.// You can add more (or less) sprites than the quantity.// grossini_dance_atlas.png is an image than contains the subsprites.AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"grossini_dance_atlas.png" capacity:50];
// You create the spriteAtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(x,y,85,121) spriteManager:mgr];
// you add the sprite to the parent// the parent must be the AtlasSpriteManager// z must be 0.// You can add tags if you want.[mgr addChild:sprite z:0 tag:kTagSprite1];
// you can transform the spritesprite.position = cpv( 200,300 );sprite.rotation = 90;sprite.scale = 2.0f;
// you can run actions in this new sprite[sprite runAction: [RotateBy actionWithDuration:2 angle:360]];
The TestAtlas.m file (Example #5) contains a working example of AtlasSprite.
The PerformanceTest example compares Sprite vs AtlasSprite performance (more on this later).
Published on
March 11, 2009 in
cocos2d.

cocos2d-iphone started as a port of cocos2d-python and during the port most of the function names remained exactly the same. For example, in cocos2d-python to add child to a parent you should do this:
parent.add( child )
and in cocos2d-iphone you should do this:
[parent add:child];
But the name add does not follow the objective-c convention. So, in v0.7.1 these functions will be deprecated. This means that these functions will be still present during the v0.7 series. A warning will be displayed at compile time and at runtime (in debug mode only) but they will still work as expected.
In v0.8 these functions will be removed.
These are the new functions:
Add:
[self add:node]; // OLD[self addChild:node]; // NEW
[self add:node z:0]; // OLD[self addChild:node z:0]; // NEW
[self add:node z:0 tag:t]; // OLD[self addChild:node z:0 tag:t]; // NEW
[self add:node z:0 tag:t parallaxRatio]; // OLD[self addChild:node z:0 tag:t parallaxRatio]; // NEW
Get:
[self getByTag:tag]; // OLD[self getChildByTag:tag]; // NEW
Remove:
[self remove:node]; // OLD[self removeChild:node cleanup:NO]; // NEW
[self removeAndStop:node]; // OLD[self removeChild:node cleanup:YES]; // NEW
[self removeByTag:tag]; // OLD[self removeChildByTag:tag cleanup:NO]; // NEW
[self removeAndStopByTag:tag]; // OLD[self removeChildByTag:tag cleanup:YES]; // NEW
[self removeAll]; // OLD[self removeAllChildrenWithCleanup: NO]; // NEW
[self removeAndStopAll]; // OLD[self removeAllChildrenWithCleanup: YES]; // NEW
Actions:
[self do: action]; // OLD[self runAction: action]; // NEW
It is noteworthy the new cleanup parameter. If you want to stop all running actions and/or scheduled functions in a node, use the cleanup parameter with YES.
Recent Comments