Archive for the 'cocos2d' Category

Sapus Tongue Source Code v1.9.2 released

Sapus Tongue v1.9.2 source code has been released.

Changes:

  • Buttons: buttons are loaded using CCSpriteFrameCache (faster loading times, consumes less memory)
  • BuyNode & SelectCharNode: uses CCSpriteFrameCache & SpriteSheet (faster loading times, consumes less memory, faster rendering times)
  • SapusIntroNode: reuses Default.png instead of loading a new image
  • GameNode: using better hash values for Chipmunk
  • Uses cocso2d v0.99.0-rc + blend fix (SVN r1761)
  • Uses Chipmunk v5.1

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.

Joystick download

LevelSVG is using a modified version of cocos2d‘s Joystick implementation.

The main differences are:

  • It supports a Jump button
  • It renders the Joystick (pad and button)

This implementation is not yet committed in the cocos2d repository since it has some hardcoded values, and is focused on games that uses stick + button. The cococs2d’s version is focused on dual stick games.

In case you are interested in it, you can download it from here: joystick-20100122.tar

LevelSVG map editor

My second game will be a platform game.
One of the most time-consuming tasks in developing platform games is creating good level maps. Therefore, I have put a lot of effort in trying to ease this task by creating an SVG parser that supports:
  • Basic physics objects like: rect, circle, lines, bezier paths and nested transformations
  • The possibility to edit physics properties like: density, friction, restitution and isSensor
  • The possibility to link SVG elements with pre-defined physics objects and cocos2d sprites
  • Collision detection logic between these elements
  • Jump logic (the hero only jumps when touching the ground)
  • Movement logic (tilt, d-pad)
Example video:
The source code of this level “editor” will be available for purchase in a few days.

cocos2d + box2d: part II

Today I’ve been working on the editor and it is more or less functional. It is still a prototype, but it should work for very basic games.

Here is a video that shows some of it’s features.



Experimenting with cocos2d + physics engine

Coding real games is the best way to evaluate how useful a game library is (like cocos2d).

I’m really happy with cocos2d, and the way it has evolved, but I think cocos2d needs to have better integration with a physics engine (box2d, chipmunk, or any other physics engine).

And by integration I mean:

  • An easy way to edit a physics world (bodies, shapes, etc.)
  • An easy way to edit visual world (eg: using tile map)
  • An easy way to match the physics world and the visual world

Ideally all these steps should be integrated using just 1 editor.

But before coding 1 editor that integrates physics + visual worlds, I’m exploring the existent alternatives.

For example, the tiled editor is a really good tile map editor (supported since cocos2d v0.8.1), and inkscape can be used to draw physics edges. But is it easy to mix those editors ? What are the alternatives ?

Well, that’s what I’m doing now… I’m building a platform game with the idea to evaluate how easy is to code it using cocos2d.

The 1st step I took was to learn box2d. If you want to test the latest box2d version (from svn) inside the iPhone without cocos2d, use this patch. And if you want to use the latest box2d version with cocos2d, then you should use the latest cocos2d svn revision.

Did you code a platform game using cocos2d ? Would you mind sharing your experience ?

cocos2d for iPhone – New Homepage

cocos2d for iPhone has a new home page: http://www.cocos2d-iphone.org/ that contains:

In this blog I will continue to announce news regarding Sapus Media (the company behind cocos2d for iPhone), but everything related to cocos2d for iPhone will be announced on that site.

understanding pixel format in cocos2d v0.7.3

Since cosos2d v0.7.3, you can specify the texture’s pixel format of your PNG/TIFF/BMP/GIF images. The texture’s pixel format is the way the image is stored in GPU memory. Possible pixel formats:

  • RGBA8888 (32-bit) (kTexture2DPixelFormat_RGBA8888)
  • RGBA4444 (16-bit) (kTexture2DPixelFormat_RGBA4444)
  • RGB5_A1 (16-bit)(kTexture2DPixelFormat_RGB5A1)
  • RGB565 (16-bit) (kTexture2DPixelFormat_RGB565)

RGBA8888:

  • 8 bits are assigned to the red channel, 8 bits to the green channel, 8 bits to the blue channel and 8 bits to the alpha channel.
  • Use this pixel format when you need the maximum possible quality for your image.
  • But it will consume the double of memory compared to 16-bit textures. Memory is a precious resource on the iPhone
  • Usually it is also slower to render.
  • Useful for: background image of your intro scene, and for images with lots of gradient colors

RGBA4444:

  • 4 bits are assigned to the red channel, 4 bits to the green channel, 4 bits to the blue channel, and 4 bits to the alpha channel
  • It gives you good quality in all channels, good speed, good memory consumption.
  • Useful for: sprites that have different values of transparency

RGB5A1:

  • 5 bits are assigned to the red channel, 5 bits to the green channel, 5 bits to the blue channel, and only 1 bit to the alpha channel
  • It gives you good quality in RGB channels but poor quality on the A channel. It also gives you good speed and good memory consumption.
  • Useful for: sprites that have transparent parts, but the transparency is either On or Off

RGB565:

  • 5 bits are assigned to the red channel, 6 bits to the green channel, and 5 bits to the blue channel. It has no alpha channel support
  • It gives you the best possible quality for 16-bit textures, but without alpha channel support.
  • Useful for: background images in your game.

The default pixel format in v0.7.3 is RGBA8888. How to use it:

// Set the pixel format before loading the image
// RGBA 8888 image (32-bit)
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
Sprite *sprite1 = [Sprite spriteWithFile:@"test-rgba1.png"];
 
// Set the pixel format before loading the image
// RGBA 4444 image (16-bit)
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444];
Sprite *sprite2 = [Sprite spriteWithFile:@"test-rgba2.png"]; 
 
// Set the pixel format before loading the image
// RGB5A1 image (16-bit)
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGB5A1];
Sprite *sprite3 = [Sprite spriteWithFile:@"test-rgba3.png"];
 
// Set the pixel format before loading the image
// RGB565 image (16-bit)
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGB565];
Sprite *sprite4 = [Sprite spriteWithFile:@"test-rgba4.png"];
 
// restore the default pixel format
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_Default];
  • Q: Can use this technique for PVRTC images ?
  • A: No, PVRTC images have their own format. PVRTC images are faster and they consumes less memory since they are either 2-bit or 4-bit textures but the quality is not that great.
  • Q: If I use 16-bit textures, will my game load faster ?
  • A: The texture pixel format has nothing to do with the loading times of your game. The Pixel Format is how the image is stored in the GPU memory. If you want faster loading times you should reduce the size of you .PNG/GIF/TIFF/TMP image file.
  • Q: Should I use RGB565 for the images that are compressed by XCode ?
  • A: When XCode compresses the PNG images, it will create a compressed PNG image that has it’s alpha channel premultiplied in the RGB channels. The PNG format is RGB565, but you should NOT confuse a PNG format with a texture pixel format. A PNG image is understood by Photoshop and cocos2d, but the GPU knows nothing about PNG images. The PNG images need to be converted into a Texture (the format understood by the GPU). The answer is: it depends on what you want. The Image (PNG,GIF,TIFF,BMP) format is independent of the Texture format.
  • Q: If I create a PNG/BMP/TIFF/GIF image without alpha channel, can I change the texture pixel format ?
  • A: If your PNG/BMP/TIFF/GIF image has no alpha channel (premultiplied or not), then the pixel format that will be used for the texture is RGB565. It can’t be changed using the API but you can change by modifying the Texture2D.m file
  • Q: Can I change the pixel format once the texture was created.
  • A: No. Once the Texture was created you can’t modify the pixel format. But you can create new textures from the same image using different pixel formats. Just remember to remove the image from the TextureMgr!

More than 100 games are using cocos2d, 3 games in the top 10


More and more games are using cocos2d.
The complete list of known games that are using cocos2d is here: Games using cocos2d. There are more than 100 games without including free/demos versions.

Also, 3 cocos2d games are in today’s Top 10 free games list!:

It is worth noting that StickWars continues to be in the Top 10 paid App list (it’s ranked #2). I think that it has been the #1 Top paid App for at least 3 weeks.

Top Paid App is using cocos2d and cocos Live


There are a lot of games in the App Store which are using cocos2d and cocos Live:

The number of games using cocos2d / cocos Live is growing fast. At present there are more than 80 games using cocos2d and more than 30 games using cocos Live.

Also, I’ve been recently informed that the top paid application is StickWars, which uses cocos2d and cocos Live!
Congratulations to John Hartzog for his game, and to the cocos2d community!

cocos2d for iPhone v0.7.2 released

cocos2d_67cocos2d for iPhone v0.7.2 is available for download:
http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-0.7.2.tar.gz

Release Notes:
http://code.google.com/p/cocos2d-iphone/source/browse/branches/branch-0.7/tools/convert_0_7_1_to_0_7_2.txt

Highlights:

  • Sound Engine plays ogg vorbis files
  • Many improvements in AtlasSprites / TextureAtlas
  • Performance and stability improvements in actions / scheduler


Full Changelog:

  • All: removed chipmunk macros. using CG macros (issue #290)
  • Actions: Added TintTo and TintBy (issue #204)
  • AtlasSprite: don’t overwrite index 0 (issue #283)
  • AtlasSprite: Supports Z-order (issue #275)
  • AtlasSprite & Sprite: don’t auto center sprite when setting frame (issue #281)
  • AtlasSprite: don’t render in subpixels (issue #135)
  • AtlasSpriteManager: supports transformations (issue #308)
  • AtlasSpriteManager: fixes in removeChild (issue #296)
  • AtlasSpriteManager: works with capacity=1 (issue #305)
  • CocosNode: CocosNodeExtras merged into CocosNode (issue #292)
  • CocosNode: improved runAction/stopAction (issue #300)
  • CocosNode: possible memory leak when running actions (issue #298)
  • CocosNode: dont execute an already running action (issue #299)
  • CocosNode: children referring to deallocated parent (issue #297)
  • CocosNode: fixed “already scheduled exception” (issue #251)
  • CocosNode: don’t render in subpixels (issue #135)
  • Demos: AtlasSprite with z-order (issue #275)
  • Demos: ParticleDemo uses touches to move the center of the emitter (issue #138)
  • Demos: organized tests folder (issue #280)
  • Demos: Atlas and Sprites uses TintBy and TintTo (issue #204)
  • Demos: Menu shows how to use padding / dynamic toggle items (part of issue #249, issue #224)
  • Demos: added drawing primitives excample (part of issue #322)
  • Director: Attach uses ‘bounds’ not ‘frame’ (issue #233)
  • Director: runWithScene / end doesn’t crash/leak anymore (issue #325)
  • Director / Transitions: pushScene with Transitions works (issue #267)
  • Documentation: API doc documents free functions (issue #314)
  • Menu: an empty menu can be crated (issue #277)
  • Menu: align supports padding (issue #249)
  • Menu: align takes into account scale (issue #248)
  • Menu: MenuToggleItem supports add/remove items in runtime (issue #224)
  • Particles: Use by default fire.pvr (issue #276)
  • Particles: resetSystem actually resets the system (issue #252)
  • Particles: texture is a property (issue #282)
  • Particles: colors and vertices in 1 VBO (issue #246)
  • Primitives: deprecated all functions. New functions uses CGPoint (issue #322)
  • Scheduler: improved timer performance (issue #309)
  • SoundSupport: supports vorbis codec (issue #321)
  • Support: ccArray: a fast alternative to NSMutableArray (issue #304)
  • TextureAtlas: fixed colorarray memory leak (issue #272)
  • TextureAtlas: support for insert,remove,reorder (issue #275)
  • TextureAtlas: free indices correctly when out of memory (issue #293)
  • TextureAtlas: resizeCapacity returns BOOL instead of raise exception (issue #294)
  • TextureAtlas: prevent crash when not enough memory while allocating color (issue #295)
  • TextureNode: texture is “retain” not “assign” (issue #230 and issue #274)
  • TileMapAtlas: supports fullpath (issue #220)
  • TileMapAtlas: don’t render in subpixels (issue #135)
  • XCode project: added class model (issue #312)