-1

我正在尝试在屏幕上添加一系列浆果并让它们向左移动。它引用了一个包含级别的 plist。我改编自 Ray Winderlich Space Game 教程。屏幕上没有显示任何精灵。:/

-(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]];
    }
}
4

1 回答 1

0

检查 nextPinkBerrySpawn 是否是它应该是的。如果 curTime 不大于 nextPinkBerrySpawn 那么它不会产生任何东西。SGSK 的代码适应性很强,如果一切设置正确,您应该能够正常运行它

于 2013-04-18T23:42:10.550 回答