Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.



Can I use cocos2d for iPhone in my closed-source iPhone application?

Yes, you can.

cocos2d for iPhone is licensed under the MIT license.

If you have any doubts, please read the license

If someone buys my game, should I give him the source code?

You are NOT forced to provide the source code (open-source) of your game, even if someone buys your game in the App Store.

It is up to you whether to open-source your game or not.

Who is using cocos2d ?

Many companies, from garage based companies to big companies like Zynga and Atari.

Contributing to cocos2d

I found a bug / I have an enhancement proposal. What should I do?

Please, open a ticket in the issue tracker: http://code.google.com/p/cocos2d-iphone/issues/list .

You can also mention the bug/enhancement in the forum, but please, don’t forget to open a ticket in the issue tracker.

How do I submit a patch?

If you want to contribute code, please follow these steps:

(If you are new to git and/or GitHub, you should read Pro Git , especially the section on Contributing to a project:Small/Large Public Project )

- Download the latest cocos2d-iphone develop branch from github:

$ git clone git://github.com/cocos2d/cocos2d-iphone.git
$ cd cocos2d-iphone
$ git checkout develop
  1. Apply your changes in the recently downloaded repository
  2. Commit your changes in your own repository
  3. Create a new branch with your patch
  4. Submit your new branch to your public repository
  5. Send a “pull request” to user “cocos2d”
  6. Open a ticket in the issue tracker, and put the patch, or your commit URL there
  7. Don’t forget to describe what the patch does.

Adding a new features

New features requires:

  1. A test (or several sub-tests) that tests the new functionality
  2. New classes/methods must have doxygen strings (documentation)
  3. .m files should follow the objective-c name convention
  4. indentation: use XCode default indentation. Use tabs instead of spaces.
  5. Run the static analyzer on your code, an fix the possible bugs. If llvm reports a false-positive (eg: memory leak that it isn't) consider documenting it in the code.

Which features / patches are merged ?

If you are requesting a feature and/or requesting a merge, it will be added if it is aligned with these points:

  • Easy to use
  • Easy to extend
  • Efficient (fast / low memory needs)
  • It tackles “common” use cases
  • Patches that refactor key components might not be merged until a new version is started.

Additional comments:

  • If your patch is not merged in the next release, please, be patient.


Can I use 3D objects in cocos2d?

Yes. You can embed an external 3D engine like cocos3d.

Can I develop a game for SDK 3.x, 4.x?

Yes, cocos2d works with SDK 2.x, 3.x and 4.x

Can I use cocos2d in an iPhone / iPad/ Mac ?

Yes, cocos2d works with all the Apple devices

  • iPhone / iPod Touch 1s gen
  • iPhone 3G and iPod Touch 2nd gen
  • iPhone 3GS and iPod Touch 3rd gen
  • iPhone4 and iPod Touch 4th gen with and without High-Res mode
  • iPad
  • iPad 2
  • Mac OS X 10.5 and 10.6

What size can textures be?

There are two cases to consider, non compressed textures and PVRTC compressed textures.

For non compressed textures the textures must have power of two dimensions less than or equal to 2048 in 3rd gen devices (or newer) and 1024 in older devices.

So 16×256 is okay, 512×512 is okay but 240×320 is not.

You can still use an image that does not follow these rules but beware that it will be stored in a texture with power of two dimensions. So loading a 240×320 image will result in a 256×512 texture being created.

On newer platforms (such as iPhone 3GS) a maximum texture size of 2048×2048 is supported. Note that the maximum texture size for the iPhone 3G and lower is 1024 x 1024.

For PVRTC compressed textures the texture must have power of two dimensions and must also be square e.g 4×4, 32×32, 256×256, 1024×1024. The image that is loaded into the compressed texture is in a special format that closely matches the format stored on the GPU - consequently the image must also be a square with power of two dimensions. If you are using PVRTC compressed textures and your texture appears as solid white then one possible cause is that the image you are loading does not have square dimensions.

What is a spritesheet and why should I use it?

A spritesheet is a collection of sprites arranged on a larger sprite. This has the two advantages, first is that all sprites on the sheet will be drawn in one draw call, which is very efficient. Second is that you can use non power of two texture textures without wasting memory, like described in the previous section. Bundling sprites on a spritesheet is considered a best practice, look at the sprite section for more information.

Can I use render to texture techniques?

Yes. cocos2d already has an object for that: CCRenderTexture

Can I use dynamic alpha effects such as lights, steam, etc.?

Yes, with a combination of a frame buffer object and channel masking, drawing only occurs on the alpha channel and the appropriate blending modes. It is useful for creating effects like iSteam (editable steam layer drawn above other images), lighting (darkening layer drawn above other images with anti-aliased holes punched out for lights), a scratch off lottery ticket effect and deformable play fields. See this RenderTexture class (from cocos2d v0.8.1) and the following thread:


How can I add sound to my project?

Yes. The cocos2d templates come with CocosDenshion (the sound engine that comes with cocos2d)


The colors of my images are messed up when I run in the simulator?

Are you using a PPC based platform? If so, this is a known issue. Also, please note that PPC is not a supported platform for iPhone development.

How do I run the tests?

  1. Open the cocos2d xcode project
  2. Click: Xcode → View → Customize toolbar
  3. Then, drag Active Target and Active Executable to your top project tool bar.
  4. Select the test you want to view in both drop downs and hit Build and Go

My PNG image doesn't look like it does in Photoshop. Why not?

If your .PNG image doesn't look as good as in Photoshop, then:

Make sure that you are using an 32-bit pixel format

  [[CCDirector sharedDirector] setPixelFormat:kRGBA8]; // Default is RGB565
  [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];  // Default is RGBA8888

If you are still having problems...

If you are still having problems, then you should know that:

  • On the device, the images are created with the alpha channel pre-multiplied (on the simulator, not)
  • To render pre-multiplied-alpha images correctly, cocos2d uses this blending function:

So, if you want to have another blending function, you should do:

// cocos2d v0.7.x uses GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA as the blending function for all sprites,
// which is not correct, but if you want to emulate v0.7.x behavior, then:
[sprite setBlendFunc: (ccBlendFunc) { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }];

For further information regarding the blending function and pre-multiplied-alpha images, please read:

And if your image is white...

If your image has alpha-premultiplied, it will modify the RGB components when you you modify it's opacity component. But if you want to override this behavior, then:

[sprite setOpacityModifyRGB:NO];
faq.txt · Last modified: 2011/09/19 22:04 by codenomad
Trace: faq
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0