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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:39:30+00:00 2026-06-17T09:39:30+00:00

EDIT 4: I added a breakpoint to CCSpriteFrameCache spriteFrameByName method and cannot step over

  • 0

EDIT 4: I added a breakpoint to CCSpriteFrameCache spriteFrameByName method and cannot step over the following step (its clear to me that somehow the spriteFrames gets deleted from the CCSpriteFrameCache):

Step that cannot be stepped over

EDIT 3: Before voting to close the question actually PLEASE TRY the code below (EDIT2) using Cocos2d 2.0 and the file and plist file attached.

EDIT 2: I created a brand new GameScene test class so you can all try out the issue. It crashes as soon as the animation starts to repeat. I update the title as consequence as well.

//  GameScene2.h
//
#import <Foundation/Foundation.h>
#import "cocos2d.h"

@interface GameScene2 : CCScene {

}
@end

//  GameScene2.m
//
#import "GameScene2.h"

@implementation GameScene2
-(id)init {
    self = [super init];
    if (self != nil) {
        [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"artfile.plist"];
        CCSpriteBatchNode* batchNode = [CCSpriteBatchNode batchNodeWithFile:@"artfile.png"];
        [self addChild:batchNode];

        CCSprite * test = [CCSprite spriteWithSpriteFrameName:@"frame0.png"];
        test.anchorPoint = CGPointMake(0.5f, 0.5f);
        test.position = CGPointMake(160.0f, 160.0f);
        [batchNode addChild:test z:1];


        NSMutableArray* frames = [[NSMutableArray alloc]initWithCapacity:2];
        CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"frame0.png"];
        [frames addObject:frame];
        CCSpriteFrame* frame2  = [[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"frame1.png"];
        [frames addObject:frame2];

        CCAnimation* anim = [CCAnimation animationWithSpriteFrames:frames delay:0.3f];
        [[CCAnimationCache sharedAnimationCache] addAnimation:anim name:@"test"];
        CCAnimate * animate = [CCAnimate actionWithAnimation:anim];
        CCRepeatForever * repeat = [CCRepeatForever actionWithAction:animate];
        //CCSequence * seq = [CCSequence actions:anim, nil];

        [test runAction:repeat];
    }
    return self;
}
@end

The artfile.png looks as following:
artfile.png

And the plist file is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>frames</key>
    <dict>

        <key>frame0.png</key>
        <dict>
            <key>aliases</key>
            <array>

            </array>
            <key>spriteColorRect</key>
            <string>{{3, 40}, {76, 28}}</string>
            <key>spriteOffset</key>
            <string>{0, 0}</string>
            <key>spriteSize</key>
            <string>{150, 94}</string>
            <key>spriteSourceSize</key>
            <string>{150, 94}</string>
            <key>spriteTrimmed</key>
            <false/>
            <key>textureRect</key>
            <string>{{0, 96}, {150, 94}}</string>
            <key>textureRotated</key>
            <false/>
        </dict>

        <key>frame1.png</key>
        <dict>
            <key>aliases</key>
            <array>

            </array>
            <key>spriteColorRect</key>
            <string>{{10, 33}, {98, 32}}</string>
            <key>spriteOffset</key>
            <string>{0, 0}</string>
            <key>spriteSize</key>
            <string>{150, 94}</string>
            <key>spriteSourceSize</key>
            <string>{150, 94}</string>
            <key>spriteTrimmed</key>
            <false/>
            <key>textureRect</key>
            <string>{{0, 192}, {150, 94}}</string>
            <key>textureRotated</key>
            <false/>
        </dict>

        <key>frame2.png</key>
        <dict>
            <key>aliases</key>
            <array>

            </array>
            <key>spriteColorRect</key>
            <string>{{4, 17}, {146, 48}}</string>
            <key>spriteOffset</key>
            <string>{0, 0}</string>
            <key>spriteSize</key>
            <string>{150, 94}</string>
            <key>spriteSourceSize</key>
            <string>{150, 94}</string>
            <key>spriteTrimmed</key>
            <false/>
            <key>textureRect</key>
            <string>{{0, 0}, {150, 94}}</string>
            <key>textureRotated</key>
            <false/>
        </dict>

    </dict>
    <key>metadata</key>
    <dict>
        <key>version</key>
        <string>1.5.2</string>
        <key>format</key>
        <integer>3</integer>
        <key>size</key>
        <string>{1024, 1024}</string>
        <key>name</key>
        <string>artfile</string>
        <key>premultipliedAlpha</key>
        <false/>
        <key>target</key>
        <dict>
            <key>name</key>
            <string>default</string>
            <key>textureFileName</key>
            <string>artfile_default</string>
            <key>textureFileExtension</key>
            <string>.png</string>
            <key>coordinatesFileName</key>
            <string>artfile_default</string>
            <key>coordinatesFileExtension</key>
            <string>.plist</string>
            <key>premultipliedAlpha</key>
            <false/>
        </dict>
    </dict>
</dict>
</plist>

END OF EDIT2:

ORIGINAL QUESTION:

I get:

Assertion failure in -[CCSprite setTexture:], /Users/…/libs/cocos2d/CCSprite.m:934

It has definetely to do with the batchNode because without it it used to work…

I know that the sprite frames for the animation should be in the same sprite sheet, and that’s the case. I have no idea how to solve this apart that it must be something to do with the use of batch node.

//
//  Navigator.h
@interface Navigator : CCLayer {

}
//Batch Nodes
@property(readwrite, nonatomic) CCSpriteBatchNode* batchNode;


//  Navigator.m
@implementation Navigator
@synthesize batchNode;

+(id) scene {
    CCScene *scene = [CCScene node];
    Navigator *layer = [Navigator node];//??
    [scene addChild:layer];
    return scene;
}

-(void) loadStuff{
    [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"art1-hd.plist"];
    batchNode = [CCSpriteBatchNode batchNodeWithFile:@"art1-hd.png"];
    [self addChild:batchNode];

    CCSprite * test = [CCSprite spriteWithSpriteFrameName:@"emptyCircle0.png"];
    test.anchorPoint = CGPointMake(0.5f, 0.5f);
    test.position = CGPointMake(160.0f, 160.0f);
    [batchNode addChild:test z:1];


    NSMutableArray* frames = [[NSMutableArray alloc]initWithCapacity:2];
    CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"emptyCircle0.png"];
    [frames addObject:frame];
    CCSpriteFrame* frame2  = [[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"emptyCircle1.png"];
    [frames addObject:frame2];

    CCAnimation* anim = [CCAnimation animationWithSpriteFrames:frames delay:0.3f];
    //[[CCAnimationCache sharedAnimationCache] addAnimation:anim name:@"test"];
    CCAnimate * animate = [CCAnimate actionWithAnimation:anim];
    CCRepeatForever * repeat = [CCRepeatForever actionWithAction:animate];
    //CCSequence * seq = [CCSequence actions:anim, nil];

    [test runAction:repeat];
}


-(id)init
{
    CCLOG(@"Navigator init");
    if((self=[super init])){
        CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
        [self loadStuff];
        }
    return self;
}

EDIT: I checked the source code of CCSprite setTexture and here is what I see. However the console log does say only NSAssert without giving the log message of what is the problem. Adding a breakpoint it seems to fail the first NSAssert but I am not 100% sure as the App goes immediately to this image:

Image

-(void) setTexture:(CCTexture2D*)texture
{
    // If batchnode, then texture id should be the same
    NSAssert( !batchNode_ || texture.name == batchNode_.texture.name , @"CCSprite: Batched sprites should use the same texture as the batchnode");  

    // accept texture==nil as argument
    NSAssert( !texture || [texture isKindOfClass:[CCTexture2D class]], @"setTexture expects a CCTexture2D. Invalid argument");

    if( ! batchNode_ && texture_ != texture ) {
        [texture_ release];
        texture_ = [texture retain];

        [self updateBlendFunc];
    }
}
  • 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-17T09:39:30+00:00Added an answer on June 17, 2026 at 9:39 am

    I found the reason why this was happening… I was calling the [self startGame] method from a previous scene and then the cleanup method was being called calling also the piece of code where I was removing sprites from the texture cache.

    Stupid me that I didn’t thought about this properly. The object Navigator scene gets created and the texture loaded, but in the meanwhile (Before the animation actually starts) the previous scene cleanup call executes the [CCSpriteFrameCache purgeSharedSpriteFrameCache]; call.

    Stupid me!

    -(void) startGame
    {
        [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[Navigator scene] withColor:ccc3(255, 255, 255)]];
    }
    
    -(void) cleanup
    {
    //    [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrames];
        [super cleanup];
    
    
        [CCTextureCache purgeSharedTextureCache];
        [CCSpriteFrameCache purgeSharedSpriteFrameCache];
        [CCAnimationCache purgeSharedAnimationCache];
    
        //Remove music
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to translate the following code from Java to Scala: EDIT: added if-statements
In the following code why does mockTest.ToString() return Null? EDIT: Added comment into example
EDIT: Added Source Project --> I uploaded a sample project that clearly shows my
Say I have a query the following query run: Edit Added order clause because
Edit: Added code (Exception on line 095, 5th time it's hit.) public DataTable ParseBarcodes(String[]
EDIT: I added in where I create new instance of the class Process as
EDIT I added this note to explain why I keep this question here. I
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
EDIT : Accepted answer points out what my issue was. I added another answer
I have a piece of code: EDIT: The _penParams are initialized as the added

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.