-1

I'm trying to add an array of berries to the screen and have them move across to the left. It references a plist which includes the levels. I adapted this from the Ray Winderlich Space Game tutorial. No sprites are showing up on the screen. :/

-(void)updatePinkBerries:(ccTime)dt
{
    CGSize winSize = [CCDirector sharedDirector].winSize;

//    if (levelManager.gameState != GameStateNormal)
//        return;
//    
//    if (![levelManager boolForProp:@"SpawnAsteroids"])
//        return;

    double curTime = CACurrentMediaTime();

    if (curTime > nextPinkBerrySpawn)
    {
        // Figure out the next time to spawn a berry
        float spawnSecsLow = [levelManager floatForProp:@"ASpawnSecsLow"];
        float spawnSecsHigh = [levelManager floatForProp:@"ASpawnSecsHigh"];

        float randSecs = randomValueBetween(spawnSecsLow, spawnSecsHigh);
        nextPinkBerrySpawn = randSecs + curTime;

        float randY = randomValueBetween(0.0, winSize.height);

        float moveDurationLow = [levelManager floatForProp:@"AMoveDurationLow"];
        float moveDurationHigh = [levelManager floatForProp:@"AMoveDurationHigh"];
        float randDuration = randomValueBetween(moveDurationLow, moveDurationHigh);

        // Create a new berry sprite
        CCSprite *pinkBerry = [pinkBerries nextSprite];
        [pinkBerry stopAllActions];
        pinkBerry.visible = YES;

        // Set its position to be offscreen to the right
        pinkBerry.position = ccp(winSize.width + pinkBerry.contentSize.width/2, randY);

        // Move it offscreen to the left, and when it's done, call removeNode
        [pinkBerry runAction:
         [CCSequence actions:
          [CCMoveBy actionWithDuration:randDuration position:ccp(-winSize.width- pinkBerry.contentSize.width, 0)],
          [CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil]];
    }
}
Kara
  • 6,115
  • 16
  • 50
  • 57
Surz
  • 984
  • 3
  • 11
  • 36
  • 2
    If you just copy & paste no doubt it didn't work. Don't be lazy, just try to debug and show us your debug process. – Shane Hou Apr 13 '13 at 05:42
  • I had similar code but not as efficient which didn't use the floatForProp's from the plist; so, it must have to do something with the plist...But the plist is fine...and I know this code is 'workable' so i was wondering if anyone with a better 'eye' than me could see a technical error? – Surz Apr 13 '13 at 05:49
  • Runtime error....they just don't load...the code 'works' from what I read. – Surz Apr 13 '13 at 05:51
  • try to reduce question length !!! – iPhoneProcessor Apr 13 '13 at 06:32
  • The what's the debugger output? You can't expect us to know what's wrong by only read your code. Show the debugger's output and try to limit the range of error. – Shane Hou Apr 13 '13 at 07:27

1 Answers1

0

Check to see if nextPinkBerrySpawn is what it is supposed to be. If curTime is not greater than nextPinkBerrySpawn then it wont spawn anything. The code from the SGSK is very adaptable and you should be able to run it fine if everything is set up right