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 9296071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:45:17+00:00 2026-06-18T21:45:17+00:00

When I didn’t optimize animation,it worked well.But when I optimized my animation,the program crashed.And

  • 0

When I didn’t optimize animation,it worked well.But when I optimized my animation,the program crashed.And Xcode log said:

Assertion failure in -[CCSpriteBatchNode addChild:z:tag:], /Users/hanpengbo/Documents/Xcode/cocos2d_helloWorld/cocos2d_helloWorld/libs/coco‌​s2d/CCSpriteBatchNode.m:183

in CCSpriteBatchNode.m:183,there is

NSAssert( child.texture.name == textureAtlas_.texture.name, @"CCSprite is not using the same texture id");

here is my code

// cache
    CCSpriteFrameCache *cache=[CCSpriteFrameCache sharedSpriteFrameCache];
    [cache addSpriteFramesWithFile:@"birdAtlas.plist"];

    // frame array
    NSMutableArray *framesArray=[NSMutableArray array];
    for (int i=1; i<10; i++) {
        NSString *frameName=[NSString stringWithFormat:@"bird%d.png", i];
        id frameObject=[cache spriteFrameByName:frameName];
        [framesArray addObject:frameObject];
    }

    // animation object
    id animObject=[CCAnimation animationWithFrames:framesArray delay:0.1];

    // animation action
    id animAction=[CCAnimate actionWithAnimation:animObject restoreOriginalFrame:NO];
    animAction=[CCRepeatForever actionWithAction:animAction];

    // sprite
    cocosGuy = [CCSprite spriteWithFile: @"Icon.png"];//cocosGuy is CCSprite,declared earler
    cocosGuy.position = ccp( 200, 300 );

    // batchNode
    CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"birdAtlas.png"];
    [self addChild:batchNode];
    [batchNode addChild:cocosGuy];

    [cocosGuy runAction:animAction];

UPDATE:
here is the corrected code,and it works well

    // batchNode
    CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"birdAtlas.png"];
    [cocosGuy setTexture:[batchNode texture]];
    [self addChild:batchNode];
    [batchNode addChild:cocosGuy];
  • 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-18T21:45:19+00:00Added an answer on June 18, 2026 at 9:45 pm

    For this to work, your Icon.png texture should be in the birdAtlas.png texture, with appropriate declaration in the .plist. Batchnodes 1) are created with one texture (and only one), and 2) only accept as children sprites that are from the SAME texture.

    … and , i dont know your intent, but typically you would have

    CCSprite *cocosGuy = [CCSprite spriteWithSpriteFrame:[cache spriteFrameByName:@"bird1.png"];
    

    in that case, i think the batch node add will work.

    … and , not sure using a batch node will be of any consequence for an animation, if the texture only contains the animation frames for that one animation. Frames are displayed one at a time, so i dont think you will benefit from the batched draw call.

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

Sidebar

Related Questions

I didn't use NGen before but now I need to improve startup performance of
I didn't design this table, and I would redesign it if I could, but
didn't find anything in related questions. Most probably it's super noob, but I'll ask
I didn't use subviews but painted my things with -drawRect: inside an UIView subclass.
I didn't think I made any tweaks to my machine configuration lately but all
(Didn't mean to create a new question, but revised the old one enough that
I didn't know how to express this problem that well in word form so
I didn't notice it until I finished the validation but I realized that even
i didn't tested this code on iPhone but i'm sure (tested) it doesn't works
Didn't even know how to exactly phrase this question, but here is the the

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.