Yes, you can.
cocos2d for iPhone is licensed under the MIT license.
If you have any doubts, please read the license
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.
Many companies, from garage based companies to big companies like Zynga and Atari.
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.
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
New features requires:
If you are requesting a feature and/or requesting a merge, it will be added if it is aligned with these points:
Additional comments:
Yes. You can embed an external 3D engine like cocos3d.
Yes, cocos2d works with SDK 2.x, 3.x and 4.x
Yes, cocos2d works with all the Apple devices
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.
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.
Yes. cocos2d already has an object for that: CCRenderTexture
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:
Yes. The cocos2d templates come with CocosDenshion (the sound engine that comes with cocos2d)
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.
If your .PNG image doesn't look as good as in Photoshop, then:
[[CCDirector sharedDirector] setPixelFormat:kRGBA8]; // Default is RGB565 [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; // Default is RGBA8888
If you are still having problems, then you should know that:
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
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:
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];