CCBReader icon indicating copy to clipboard operation
CCBReader copied to clipboard

Exception when adding a CCScale9Sprite to the a CCB

Open tklee1975 opened this issue 12 years ago • 1 comments

When putting a CCScale9Sprite on the CCLayer Interface file; Cocos2d version: cocos2d-iphone v2.1 CCBReader version: #define kCCBVersion 5

Exception raise at the following location: File: CCNode+CCBRelativePositioning.m

#ifdef __CC_PLATFORM_IOS
    [self setValue:[NSValue valueWithCGSize:absSize] forKey:propertyName];
#else
    [self setValue:[NSValue valueWithSize:NSSizeFromCGSize(absSize)] forKey:propertyName];
#endif 

It will be fine if the "[self setValue]" removed or create a method "setValue" in CCScale9Sprite.m

Sorry that I don't know how to fix it yet!

Regards, ken

tklee1975 avatar Nov 02 '13 09:11 tklee1975

Solution for this problem: Add the following method to CCScale9Sprite.m

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    // NSLog(@"key=%@", key);   // uncomment if want to debug
    if([key isEqualToString:@"preferedSize"]) {
        CGSize size = [value CGSizeValue];
        self.preferredSize = size;
    }
}

Note: the key is defined as "preferedSize" but not "preferredSize"; it may be something wrong in the exported CCB files.

tklee1975 avatar Nov 02 '13 15:11 tklee1975