-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 に答える