3 Replies - 331 Views - Last Post: 27 June 2013 - 03:40 AM Rate Topic: -----

#1 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 158
  • Joined: 15-February 11

CCSprite and CCSpriteBatchNode

Posted 26 June 2013 - 04:54 PM

I've been making a game and most of my images were placed in a sprite frame using Texture Packer. The sprites are then put int a batchNode like this:
self.allSprites = [CCSpriteBatchNode batchNodeWithFile:@"AllSprites.pvr.ccz"];
        [self addChild:self.allSprites];
        [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"AllSprites.plist"];



And then used like this:

CCSprite *okButtonSprite = [CCSprite spriteWithFrameName:@"okButton.png"];



Sometimes to do something quickly i simply put the image in my resources folder and created a sprite like this:
CCSprite *okButtonSprite = [CCSprite spriteWithFile:@"okButton.png"];



As my project is nearing completion I went through the sprites that were not in the frame and added them, then removed the images from the resources folder. I went through the code to change all the spriteWithFile to spriteWithFrameName. My question is: I forgot to change a few calls and yet the code is not producing errors and is showing the images correctly. The unchanged code should produce an error when trying to get an image from resources that does not exist. I cleaned the build and still working? What's going on... there must be some sort of cache somewhere where it is finding the image file...

I know it's funny to be complaining because code is compiling and working but I expect that this will not work on another machine. Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: CCSprite and CCSpriteBatchNode

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: CCSprite and CCSpriteBatchNode

Posted 26 June 2013 - 05:29 PM

There are a number of things you can try to inspect what is going on:

1. Learn to use debug tools.
2. Put exception handling in your code.
3. Ensure you are correctly releasing previously successfully loaded resources.
Was This Post Helpful? 0
  • +
  • -

#3 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 158
  • Joined: 15-February 11

Re: CCSprite and CCSpriteBatchNode

Posted 26 June 2013 - 05:32 PM

View PostButchDean, on 26 June 2013 - 05:29 PM, said:

There are a number of things you can try to inspect what is going on:

1. Learn to use debug tools.
2. Put exception handling in your code.
3. Ensure you are correctly releasing previously successfully loaded resources.

Could you expand on #3, thanks!
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: CCSprite and CCSpriteBatchNode

Posted 27 June 2013 - 03:40 AM

Are you familiar with Obj-C's object reference counting? Essentially you need to make sure that the reference to a resource is removed when no longer needed, removing it from the memory pool.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1