Modifying the game to use spritesheets: createBatchNode wrong Code?

Home Forum Learning iPhone Game Development with Cocos2D 3.0 Modifying the game to use spritesheets: createBatchNode wrong Code?

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #297
    Kirill Muzykov
    Keymaster

    Hi,

    Yes. This is a sad typo made at the stage when the book was laid out for PDF. Final drafts that I sent had the correct version.

    Please check the Support tab on the book’s official page for errata related fixes.

    Regarding this exact typo:

    The following 6th bullet point:

    In the GameScene.m file, add the createBatchNode method as follows:

    -(void)addBird 
    { 
           CGSize viewSize = [CCDirector sharedDirector].viewSize; 
           _bird = [[Bird alloc] 
                      initWithBirdType:BirdTypeSmall]; 
           _bird.position = ccp(viewSize.width * 0.5f, 
                                       viewSize.height * 0.9f); 
           [_batchNode addChild:_bird]; 
    }

    Should be:

    In the GameScene.m file, add the createBatchNode method as follows:

    -(void)createBatchNode
    {
         //1
         [[CCSpriteFrameCache sharedSpriteFrameCache]
         addSpriteFramesWithFile:@"Cocohunt.plist"];
    
         //2
         _batchNode = [CCSpriteBatchNode 
                             batchNodeWithFile:@"Cocohunt.png"];
         //3
         [self addChild:_batchNode z:1];
    }
    #296
    rolfchopper
    Participant

    I think I found a typo? In step 6 of “Time for action – modifying the game to use spritesheets” you say

    “In the GameScene.m file, add the createBatchNode method as follows:

    -( void) addBird { ”

    When I think you actually mean to have this code:

    -(void)createBatchNode
    {
    //Loading spritesheet sprite frames from .plist
    [[CCSpriteFrameCache sharedSpriteFrameCache]
    addSpriteFramesWithFile:@”Cocohunt.plist”];

    //Creating batchnode using spritesheet image.
    _batchNode = [CCSpriteBatchNode
    batchNodeWithFile:@”Cocohunt.png”];

    //Adding batch node to the scene (at z:1 to make sure its on top of background)
    [self addChild:_batchNode z:1];
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Learning iPhone Game Development with Cocos2D 3.0’ is closed to new topics and replies.