2013-11-04

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;

Solution: 
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.

No comments:

Post a Comment