Hello everyone,
I'm making a TweeJump-based game, and I successfully updated it to cocos2d 1.0.1. However, I have a problem with the following code in Game.m:
- (void)initPlatform
{
// Old platform code
CGRect rect;
switch(random()%2)
{
case 0: rect = CGRectMake(608,64,102,36); break;
case 1: rect = CGRectMake(608,128,90,32); break;
}
CCSpriteBatchNode *spriteManager = (CCSpriteBatchNode*)[self getChildByTag:kSpriteManager];
CCSprite *platform = [CCSprite spriteWithBatchNode:spriteManager rect:rect];
[spriteManager addChild:platform z:3 tag:currentPlatformTag];
/*
// New platform code
NSString *platformName;
switch(random()%3) {
case 0: platformName = @"Stable_Platform.png"; break;
case 1: platformName = @"Cotton_Platform.png"; break;
case 2: platformName = @"Booster_Platform.png"; break;
}
// AtlasSpriteManager *spriteManager = (AtlasSpriteManager*)[self getChildByTag:kSpriteManager];
CCSprite *platform = [CCSprite spriteWithFile:platformName rect:CGRectMake(0, 0, 256, 48)];
[self addChild:platform z:3 tag:currentPlatformTag];
*/
}
If I uncomment the stuff labeled as old platform code and comment off the stuff labeled as new code, it works fine with the default images that TweeJump uses. However, if I run it as shown, with the new code enabled, then it shows one platform at the bottom-left-hand corner of the screen, with no other platforms visible. I can't see how changing the code from batch nodes to individual sprites would cause such erratic behavior (and yes, I will make sprite sheets with Zwoptex when it's time to optimize performance). Please help, it's important for this game to have some variety in its platforms...and their behaviors.
MachCUBED