List of Patches for Cocos2d iphone

Here are the solutions for the problem you may encounter when using Cocos2d-iphone with CocosBuilder Extension.

Cocos2d-iphone Version: 2.0.0
CCBReader: v3

1. CCScrollView not showing and handle touch correct if the parent position is not CGZero

2. CCLayerColor and CCLayerGradient cannot  show color

3. CCControl doesn't change to Disable Look when control.enable = NO


List of "Got Stuck"

This is the list of technical issue that I got stuck :

Install pecl_http on Mac (MAMP) / 18 Nov 2013 

Work around Solution: using curl function instead

More Information:

  • PHP about PECL_HTTP: http://us3.php.net/manual/en/http.install.php
  • CURL Usage: http://us3.php.net/manual/en/book.curl.php


PHP Not Refresh

If you are using MAMP & Php 5.5.3, and found that the php logic is not updated; Try to close the cache config; See more at here: http://stackoverflow.com/questions/19079089/mamp-time-between-seeing-live-changes


Fixing CCBReader v.3 with Cocos2d-iphone v2.0.0

1. Occur Exception at CCLayer

Add the “setTouchEnable” method to CCLayer(at CCLayer.m)

- (void)setTouchEnabled:(BOOL)enabled
     [self setIsTouchEnabled:enabled];

2. Cannot see CCLayerColor properly
Add the follow code segment in CCBReader just before the code "if ([node isKindOfClass:[CCBFile class]])” in the method called "(CCNode*) readNodeGraphParent:(CCNode*)parent"

if([node isKindOfClass:[CCLayerColor class]]){
     [(CCLayerColor *)node setOpacity:255];

3. Cannot see CCLayerGradient properly

Add the “init” method to CCLayerGradient  (at CCLayer.m)
- (id) init
     return [self initWithColor:ccc4(0, 0, 0, 255) fadingTo:ccc4(0, 0, 0, 255)];

4. CCControl doesn't change to Disable Look when control.enable = NO

Problem: When CCBReader generate the ccbi, it use "3" as the disable state, but it is "4" is iOS now;

Place the following in "CCBReader.m" at Method "readPropertyForNode" right before "if ([node isKindOfClass:[CCBFile class]])"

// Fix for DisableState
 if ([node isKindOfClass:[CCControl class]]) {
  // the disable state value is wrong!!!!
  //  CCBReader use 3 as CCControlStateDisabled, but it is 4 in iOS now
  // Change "|3" -> "|4"
  name = [name stringByReplacingOccurrencesOfString:@"|3" withString:@"|4"];

Remark CocosBuilder is an user interface builder worth to integrate to your project; It can make your code more tidy and easy to modify later. This is the screen capture of the Demo GUI using CocosBuilder.


Fixing CCBReader problem for CCScale9Sprite

Today, when making some unit tests to check the behaviour of the CCBReader (CocosBuilder Reader); 
Found 2 issues when adding a CCScale9Sprite to the Interface;

1. Crash if the interface included a CCScale9Sprite Node:

2. The CCScale9Sprite Node have a wrong opacity setting

Hope this small pieces of information helps