Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:16:20+00:00 2026-06-05T23:16:20+00:00

when diving into learn cocos2d game development with ios5, in ch08 in EnemyCache.m -(id)

  • 0

when diving into “learn cocos2d game development with ios5”, in ch08

in EnemyCache.m

-(id) init
{
    if ((self = [super init]))
    {
        // get any image from the Texture Atlas we're using
        CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"monster-a.png"];
        batch = [CCSpriteBatchNode batchNodeWithTexture:frame.texture];
        [self addChild:batch];

        [self initEnemies];
        [self scheduleUpdate];
    }

    return self;
}

so batch is with texture “monster-a.png”

in EnemyEntity.m‘s initWithType method

switch (type)
{
    case EnemyTypeUFO:
        enemyFrameName = @"monster-a.png";
        bulletFrameName = @"shot-a.png";
        break;
    case EnemyTypeCruiser:
        enemyFrameName = @"monster-b.png";
        bulletFrameName = @"shot-b.png";
        shootFrequency = 1.0f;
        initialHitPoints = 3;
        break;
    case EnemyTypeBoss:
        enemyFrameName = @"monster-c.png";
        bulletFrameName = @"shot-c.png";
        shootFrequency = 2.0f;
        initialHitPoints = 15;
        break;

    default:
        [NSException exceptionWithName:@"EnemyEntity Exception" reason:@"unhandled enemy type" userInfo:nil];
}

if ((self = [super initWithSpriteFrameName:enemyFrameName]))
{
    //...
}

so the returned object may be in 3 different frame. since Only the CCSprites that are contained in that texture can be added to the CCSpriteBatchNode, obviously, ‘monster-b.png’ is not contained in ‘monster-a.png’, why the different enemy can still be added to the batch?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:16:21+00:00Added an answer on June 5, 2026 at 11:16 pm

    It is possible to place multiple images in to one. Such image is called an atlas. So all the monsters are in one big texture. The access to each image is done using .plist configuration filed where the information about where concrete image is placed in the big texture is stored.

    It has a lot of sense because it’s an expensive operation to swtich textures. Much faster is to place everything you need in to one texture and use batching. Also it also takes less memory on the GPU since textures are stored in (2^n, 2^m) buffers on the GPU and providing a big texture you are able to minimize the free space in texture. For example loading an image of size 65 per 65 pixels will create a 128 per 128 pixels texture.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm diving into iOS development and I just built my first game. Since Apple
I am diving into the world of packaging Python applications and managed to get
I just started diving into Metro Style application development and I realized that there
I'm diving into iPhone development, so I apologize in advance if this is a
I'm trying to learn some NHibernate after diving into EF4. Is the equivalent of
I'm diving into iOS development and when I try to load a specific Facebook
I'm diving into iOS development and I'm still getting familiar with the NSString object.
I'm diving into iOS development and I'm building a navigation based app that wasn't
I'm diving into web development and CSS is getting the best of me very
I'm diving into web development and I've built a few basic rails apps, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.