Wednesday, March 11, 2009

deprecated API in v0.7.1


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.

No comments: