* Base SDK 4.1 or newer should be used. Don't report bugs if you are using a previous version. Don't you have Base SDK 4.1 ? Install Xcode 3.2.4 or newer.
How to set Base SDK to 4.1: Xcode → Project → Edit project Settings → Build → Base SDK
You can download cocos2d for iPhone v0.99.5 from here:
You can find the v0.99.5 documentation here:
If you are new to v0.99.x, you should also read:
To understand how fast cocos2d v0.99.5 is, please see the performance tests
IMPORTANT : If you notice an slowdown while loading JPG images, see below, Issue #886
Since cocos2d v0.99.5-beta3, you can develop your games both for RetinaDisplay and non RetinaDisplay easily since the cocos2d API was converted to Points (and not Pixels).
It is still possible to use the Pixels API if you want, but 99% of the times you'll like to develop your game in “Points”.
To learn how to develop Retina Display games in cocos2d, please read: How to develop RetinaDisplay games in cocos2d
cocos2d / CocosDenshion work on Mac!
Yes, the game that you have coded using cocos2d / CocosDenshion can be used on Mac too.
Basically all the cocos2d / CocosDenshion functionality is present except:
CCDirector / OpenGL View: For the moment the only way to create an OpenGL View is using the Interface Builder. Please see the samples
CCRenderTexture: save image is not supported yet
CCTexture2d / CCLabelTTF: FontLabel (ZLabel) is not supported
CCParticleSystemPoint: Will use CCParticleSystemQuad.
Accelerometer / Touches / TouchDispatcher: They were replaced by Keyboard / Mouse events and the EventDispatcher
Additional features:
Fullscreen / Window mode: Cmd+f switches between Fullscreen and Window mode
Autoresize: (EXPERIMENTAL) If you resize the window, the OpenGL window will be resized too. It doesn't work well with “effects” yet.
The cocos2d-mac project contains several tests that can be used to teach yourself how to develop a cocos2d-mac game.
A cocos2d-mac template is also included.
Issue 848
A new class called CCAnimationCache was added.
Its main responsibility it to cache CCAnimation objects. Think of a dictionary of CCAnimation objects.
This objects deprecates the CCSprite.animation property.
Sample:
SpriteTest.m
Issue 938
Fixed texture artifacts in CCSprite, CCTMXTileMap, CCLabelBMFont, CCLabelAtlas, CCTiledMap and CCParticleSystemQuad.
Benefits:
There is no need to use the “spritesheet-artifac-fixer.py” to prevent artifacs
There is no need to use borders around the sprites / tiles in the spritesheets
You use aliasing or anti-aliasing textures
For further info, please see this thread
To enable this functionality you should edit ccConfig.h and:
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 1 // <-- Should be 1
The EAGLView (iOS only) supports multisampling anti-aliasing (MSAA) and sharegroups.
In case you don't know, the sharegroup can be used reuse already created textures.
And MSAA is useful to create a fullscreen anti alias scene. Use it with careful since it might slow down your game.
Sample of MSAA:
// Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits
EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGBA8
depthFormat:GL_DEPTH_COMPONENT24_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:YES
numberOfSamples:4];
Added support for Gradient Layer.
Example:
// Anchor Point works as expected
CCLayerGradient* layer1 = [CCLayerGradient layerWithColor:ccc4(255,0,0,255)
fadingTo:ccc4(0,255,0,255)
alongVector:ccp(1,0)];
Example:
// Anchor Point works as expected
CCLabelBMFont *label2 = [CCLabelBMFont labelWithString:@"Multi line\nCenter"
fntFile:@"bitmapFontTest3.fnt"];
label2.anchorPoint = ccp(0.5f, 0.5f);
This gives a ~5% increase in ARMv6 processors (iPhone and iPod Touch 1st and 2nd generation)
#define CC_USE_RGBA32_LABELS_ON_NEON_ARCH 1 // It must be 1.
If this setting is enabled, then the CCLabelTTF objects, in ARMv7 devices, will create RGBA8888 (32-bit images) instead of A8 (8-bit images). The result is:
Updated Chipmunk to to version 5.3.4
Added support for PVR, PVR.GZ and PVR.CCZ textures:
Supported PVR formats:
Benefits/Limitations of PVR images:
Background:
- The problem with .PNG images is that the loading time usually is somewhat slow.
- And the problem with the .PVR images is that they occupy a lot of “disk” space on the device.
So, the compressed PVR image tries to solve both problems: a format that doesn't occupy a lot of space on the device with fast loading times.
IMPORTANT: Before using this format it is suggested to read the performance tests since there are situations where the .PNG format has more or less the same loading time, but consuming much less disk space.
To generate .pvr.gz images, use gzip:
$ gzip image.pvr
To generate .pvr.ccz images:
$ cd cocos2-iphone/tools
$ ./ccz-compile.sh
* and execute it like gzip
$ ccz image.pvr
The commercial tools TexturePacker and Zwoptex also support the ccz format.
In order to have a cleaner and easier to use API, many classes and methods were renamed in v0.99.5.
Unless you were using custom actions, you won't need to update your code.
List of renamed classes:
| Old | New |
CCInstantAction | CCActionInstant |
CCIntervalAction | CCActionInterval |
CCCameraAction | CCActionCamera |
CCEaseAction | CCActionEase |
CCGridAction | CCActionGrid |
CCPageTurn3DAction | CCActionPageTurn3D |
And the CCPropertyAction was also renamed to:
| Old | New |
CCPropertyAction | CCActionTween |
Changes:
Unless you were using a custom director, you won't need to update your code.
| Old | New |
CCFastDirector | CCDirectorFast |
CCTimerDirector | CCDirectorTimer |
CCDisplayLinkDirector | CCDirectorDisplayLink |
CCFastThreadedDirector | CCDirectorFastThreaded |
Changes:
Updated class names
| Old | New |
CCLabel | CCLabelTTF |
CCBitmapFontAtlas | CCLabelBMFont |
Updated method names in CCLabelBMFont:
| Deprecated | New |
+(id) bitmapFontAtlasWithString:(NSString*)string fntFile:(NSString*)file | +(id) labelWithString:(NSString*)string fntFile:(NSString*)fntFile |
Updated method names in CCLabelAtlas:
| Deprecated | New |
+(id) labelAtlasWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(int)w itemHeight:(int)h startCharMap:(char)c | +(id) labelWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(int)w itemHeight:(int)h startCharMap:(char)c; |
| Old | New |
CCColorLayer | CCLayerColor |
Changes:
Updated class names
| Old | New |
CCPointParticleSystem | CCParticleSystemPoint |
CCQuadParticleSystem | CCParticleSystemQuad |
Changes:
Renamed classes:
| Deprecated | New |
CCSpriteSheet | CCSpriteBatchNode |
Renamed methods:
| CCSpriteBatchNode |
| Deprecated | New |
+(id)spriteSheetWithTexture:(CCTexture2D*) | +(id)batchNodeWithTexture:(CCTexture2D*) |
+(id)spriteSheetWithFile:(NSString*) | +(id)batchNodeWithFile:(NSString*) |
| CCSprite |
| Deprecated | New |
+(id)spriteWithSpriteSheet:(CCSpriteSheet*) | +(id)spriteWithBatchNode:(CCSpriteBatchNode*) |
-(id)initWithSpriteSheet:(CCSpriteSheet*) | -(id)initWithBatchNode:(CCSpriteBatchNode*) |
-(void) setDisplayFrame:(NSString*)animationName index:(int)frameIndex | -(void) setDisplayFrameWithAnimationName:(NSString*)animationName index:(int) frameIndex; |
-(CCAnimation*)animationByName: (NSString*) animationName | Use CCAnimationCache |
-(void) addAnimation: (CCAnimation*) animation | Use CCAnimationCache |
All the transition classes were renamed.
| Old | New |
CCXXXTransition | CCTransitionXXX |
Example:
| Old | New |
CCFadeTransition | CCTransitionFade |
[NEW] All: small performance improvements in all the code
[NEW] Layer: Added gradient layer
[NEW] MenuItem: it also supports class methods
[NEW] SpriteFrameCache: added method to load a plist file with a texture file name
[NEW] Texture: It is possible to use a subclass like MutableTexture without modifying the code
[NEW-MAC] Added Mac templates
[NEW-MAC] Added “flagsChanged” keyboard event
[NEW-MAC] Added support for Fullscreen / window mode
[NEW-MAC] Added support for AutoScale if the window is resized / fullscreen (EXPERIMENTAL)
[FIX] All: Misc cleanups in the code
[FIX] Action: Blink restores doesn't set as invisible the frame when the action is done (issue #1061)
[FIX] Camera: uses points intead of pixels. Works OK in RetinaDisplay mode (issue #1023)
[FIX] CCArray: fixed possible crash
[FIX] Configuration: checks for possible glErrors. Only ask for max samples if iOS >= 4 (issue #1041)
[FIX] Director: Fixed possible memory leak when popping a scene.
[FIX] FileUtils: loads .gz / .ccz files correctly in RetinaDisplay mode (issue #1037)
[FIX] FileUtils: fixed big memory leaks on .ccz inflater
[FIX] FileUtils: removes -hd suffix if the filename already has it (issue #1040)
[FIX] Node: udpated doxygen strings regarding default anchorPoint (issue #1049)
[FIX] Sprite: updateTransform can be overriden (issue #824)
[FIX] Sprite: Assert if an sprite initialized with a batchnode and it is not using it (issue #1053)
[FIX] Sprite: correctly overrides setIsRelativeAnchorPoint (issue #1055)
[FIX] SpriteFrameCache: textureFileName is relative to path (issue #1044)
[FIX] Particles: QuadParticle uses Points (issue #1057)
[FIX] Templates: removeStartup compiles (issue #1059)
[FIX] Texture: PVR with non-square mipmaps generates a warning log in debug mode (issue #1052)
[FIX-MAC] Display Link thread: async images works as expected. Enabled by default.
[FIX-MAC] MacGLView: VSync is enabled when the view is loaded from the NIB
[TEST] Added Glyph Designer test case
[TEST] Added LayerGradient test
[TEST-MAC] Added cocos2d icon to Mac tests
[TEST-MAC] Added EventTest
[3RD] Chipmunk: Updated to v5.3.4
[3RD] libpng: don't compile pngtest.c (issue #1058)
[NEW] Director: setProjection calls “updateProjection” delegate if “custom” projection is used
[NEW] Label: The CCLabelProtocol implements the -(NSString*)string method.
[NEW] Particles: Added a new type kCCPositionTypeRelative. Useful for “trail” particles. Added Test.
[NEW] Textures: Added support for pvz.ccz and pvr.gz formats
[NEW] Textures: TextureCache has a method to test if a texture is already cached (issue #793)
[NEW] ZipUtils: Added generic functions to uncompress any .gz or .ccz file (issue #1016)
[FIX] Actions: OrbitCamera doesn't crash on Simulator
[FIX] CCArray: fastRemoveObjectAtIndex works as expected (issue #1024)
[FIX] CocosDenshion: Fixed possible loss of audio on iOS 4.2
[FIX] config: CC_FONT_LABEL_SUPPORT is again, enabled by default
[FIX] Configuration: removed main bundle from CCConfiguration (issue #839 issue #773)
[FIX] Director: projection is doubled in RetinaDisplay mode
[FIX] DrawingPrimitives: don't modify the buffer in RetinaDisplay (issue #995)
[FIX] EAGLView: Doesn't crash in multithread environment (re-fixed issue #350)
[FIX] Label: BMFontLabel simplified loading of atlas. Doesn't use CCFileUtils (issue #1031)
[FIX] Label: setString copies the string, and not retain it (issue #1034)
[FIX] Mac: Events are dispatched when CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD is used
[FIX] Menu: MenuItems can draw its children (issue #458)
[FIX] Menu: MenuItems positions can be controlled manually (issue #1013)
[FIX] Menu: Menus uses touch priority kCCMenuTouchPriority (-128) (issue #1033)
[FIX] Node: convertToAR method fixed (issue #1017)
[FIX] Node: vertexZ works OK in RetinaDisplay mode
[FIX] Particles: Improved doxygen documentation (issue #1026)
[FIX] Particles: centerOfGravity renamed to sourcePosition (issue #1026)
[FIX] RenderTexture: removed unneeded and dangerous assert in getUIImageAsDataFromBuffer
[FIX] RenderTexture: fixed important memory leak when saving images
[FIX] SpriteBatchNode: improved performance when drawing the batch (issue #824)
[FIX] SpriteBatchNode: children sprites use the visible property correctly (issue #665)
[FIX] TextureCache: Improved loading time of cached PVR images (issue #998)
[FIX] Texture2D: addPVRTCImage: → addPVRImage: since it also loads non-compressed PVR images
[FIX] Texture2D: Use 32-bit textures when creating labels on ARM_NEON hardware. Performance improvement. To enable it, edit ccConfig and set CC_USE_RGBA32_LABELS_ON_NEON_ARCH = 1
[FIX] Texture2D: Improved creation time of texts. It's not so expensive to create ZFont labels (issue #971)
[FIX] Tiled: images can be relative to source map (issue #787)
[FIX] Tiled: TMXLayer checks for correct GID (issue #742)
[NEW] AnimationCache: New class. It deprecates the CCSprite#animation methods (issue #848)
[NEW] Animation: simplified
API. Name is no longer needed. Deprecated
API that uses name.
[NEW] Animation: Animation has its own file: CCAnimation.m
[NEW] CocosDenshion: Added duration, freq and size queries for buffers
[NEW] Director: Added “hook” for notifications or any other kind of object like CCNotifications
[NEW] Director: Added “enableRetinaDisplay:(BOOL)enabled”
[NEW] EAGLView: Added support for multisampling
[NEW] EAGLView: Added support sharegroup
[NEW] Templates: Install HD, iPad and spotlight icons
[FIX] Blocks: Actions and MenuItems copy the blocks instead of retaining it (issue #1007)
[FIX] config: FONT_LABEL is disabled by default since it performs really bad on iOS >= 4.0
[FIX] Layer: register accelerometer onEnterTransitionDidFinsih (issue #624)
[FIX] Node: converToNodeSpace works on RetinaDisplay (issue #1000)
[FIX] Node: all transform methods uses Points instead of Pixels (issue #999)
[FIX] Node: onEnterTransitionDidFinsih is also called when added a node to a running node (issue #1018)
[FIX] Node: addChild returns void, and not self in order to simplify the
API
[FIX] Node: Initializes parent_ to nil at init time
[FIX] Node: Performance improvement in insertChild (issue #909)
[FIX] RenderTexture: improved performance, improved logic, no more glMaskColor() bugs (issue #1012)
[FIX] Sprite: setPositionInPixels set to dirty when called (issue #1001)
[FIX] Templates: Fixed startup flicker (issue #947)
[FIX] Templates: Installs @2x, iPad and spotlight icons
[FIX] Tests: Touch Tests works on RetinaDisplay (issue #1000)
[FIX] Tests: box2d tests work with RetinaDisplay
[FIX] Transitions: PageTurnTransition re-fixed. No more artifacts. This time is for real (issue #751)
[3RD] Chipmunk: Using version 5.3.2
[NEW] RetinaDisplay supported automatically:
Director: winSize returns size in Points. Use winSizeInPixels for pixels
Node: position is in Points. Use positionInPixels for pixles
Node: contentSize is in Points. Use contentSizeInPixels for pixels
Node: boundingBox is in Points. Use boundingBoxInPixels for pixels
Texture2d: contentSize is in Points. Use contentSizeInPixels for pixels
FileUtils: Will try to load the file with the suffix ”-hd” if RetinaDisplay is enabled, unless the ”-hd” suffix is already present
The following objects were enhanced to work with points: TMXTileMap, Sprite, SpriteFrame, Node, ParticleSystem, LabelBMFont, LabelTTF, Menu, MenuItem, ColorLayer, RenderTexture, MotionStreak, Transitions, Actions, LabelAtlas, AtlasNode and the drawing primitives. The nodes that weren't updated is because there was no need to update them.
[NEW] SpriteFrameCache: Added a way to remove from the SpriteFrameCache frames given a dictionary, file or texture (issue #953)
[FIX] CCArray: improved speed in inserting and deleting elements
[FIX] ParticleSystem: fixed memory leak when using ParticleDesigner (issue #986)
[FIX] Templates: Default
SDK is 4.1
[FIX] Texture2d: Fixed possible crash in NPOT PVR images
[FIX] Texture2d: If Text in context can't be created return nil (prevent possible crash)
[FIX] Texture2d: Optimized loading time of PVR images
[NEW] Actions: files renamed: CCXXXAction.[hm] → CCActionXXX.[hm]
[NEW] Actions: Using new naming convetion:
CCInstantAction → CCActionInstant
CCIntervalAction → CCActionInterval
CCEaseAction → CCActionEase
CCCameraAction → CCActionCamera
[NEW] Action: CCPropertyAction renamed to CCActionTween
[NEW] Director: New naming convention: CCnameDirector → CCDirectorName
[NEW] Director: DirectorIOS is responsible for swapping buffers
[NEW] Label: CCLabelAtlas#labelAtlasWithString: → labelWithString. Old method deprecated
[NEW] Label: CCBitmapFontAtlas deprecated. Use CCLabelBMFont instead.
[NEW] Label: CCBitmapFontAtlas#bitmapFontAtlasWithString → labelWithString. Old method deprecated.
[NEW] Label: CCLabel renamed to CCLabelTTF
[NEW] Mac: cocos2d works on Mac. All objects works with the following exceptions:
CCParticleSystemPoint is not supported. Use CCParticleSystemQuad instead
CCRenderTexture doesn't save textures to images
ZLabel (FontLabel) is not supported
Mmm… probably a bit more.
[NEW] Particles: New naming convention:
[NEW] Transitions: new transition naming convention (issue #946)
[FIX] Actions: ivars 'duration', 'elapsed', 'tag' now have the '_' suffix in their names.
[FIX] Artifact fixer is a compile time option in ccConfig. Disabled by default
[FIX] ccCArray: off-by-1 offset, and lastObject fixed (issue #960 and #961)
[FIX] ccTypes: using GL types for CC GL structures. Prevents possible errors on 64-bit machines
[FIX] CocosDenshion: Added SDK4.0 compile check in CDAudioManager
[FIX] CocosDenshion: panning does not work correctly on iOS4 (issue #949)
[FIX] Director: Works with Fast FPS disabled (issue #954)
[FIX] Director: it's possible to set a custom projection before setting the openGL view (issue #952)
[FIX] Label: BitmapFontAtlas supports empty strings (issue #950)
[FIX] Label: LabelAtlas doesn't crash if the texture file can't be found (issue #965)
[FIX] Layer: ivars isTouchEnabled / isAccelerometerEnabled have the '_' suffix in their names
[FIX] Menu: Disabled possible menuItem on onExit (issue #969)
[FIX] Sprite: little optimization when using BatchNode + children
[FIX] Templates: Added missing keys in Info.plist (issue #939)
[FIX] Tools: mkatlas supports artifact removal (issue #549)
[FIX] Tools: mkatlas supports spaces in the name (issue #618)
[3RD] Chipmunk: updated to Chipmunk v5.3 and Chipmunk Demos
[NEW] BitmapFontAtlas: added support for multilines labels
[NEW] BitmapFontAtlas: added optional setCString method
[NEW] Configuration: added a helper method to obtain the iOS version
[NEW] Config: added CC_OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA. Enabled by default.
[NEW] Texture Atlas & Particles: Uses VBO on ARMv7 and iPhone Simulator. Uses a vertex array list on ARMv6. Performance improvment.
[NEW] Sprite: Added support for Zwoptex v1.0 (issue #913)
[NEW] SpriteFrameCache: Added support for Zwoptex name aliases (issue #935)
[NEW] SpriteSheet is deprecatd. Use SpriteBatchNode instead.
[NEW] Support/ccUtils.h: added new file that contains some useful functions like nextPOT
[NEW] RenderTexture: default blend function compatible with premultiplied alpha (issue #937)
[NEW] Tests: Zwoptex Test added
[NEW] Texture2D: Added support for Non compressed PVR images. New supported formats: RGBA_8888, BGRA_8888, RGBA_4444, RGBA_5551, RGB_565, A_8, AI_88, I_8
[NEW] Texture2D: PVR images can be treated as having alpha premultiplied with: +(void) PVRImagesHavePremultipliedAlpha:(BOOL)
[FIX] CCArray: conforms to NSCopying protocol (issue #934)
[FIX] CocosDenshion: Improved sound interruption code (issue #928)
[FIX] Particles: Built-in particles use QuadParticles when compiled in ARMv7, and PointParticles when compiled in ARMv6
[FIX] Sprites: No artifacts when using spritehsheets (issue #938)
[FIX] Templates & Tests: call CC_DIRECTOR_END() on AppDelegate Terminate
[FIX] Templates: Use LLVM-GCC as default compiler
[FIX] Tests: AtlasTest renamed to LabelTest
[FIX] Tests: CocosLive Demo: added requestRank tests
[FIX] TextureCache:
JPEG workaround (issue #866) is only applied on iOS >= 4 (issue #932)
[3RD] libpng: updated to v1.2.44 (libpng is only used by a cocos2d test)