2

I have gotten 0 response from the Cocos2D board so thought Id try here.

Ok. Im ripping out my hair over this. I did a complete re-haul of my code last night in hopes of fixing some iphone4 framerate issues. I created sprites in advance instead of doing some of the creation during the update methods. I only add them to the spritesheet now in the update method as needed.

However, this really didnt fix the issue. So I changed one thing out of curiosity. My main sprite sheet is 2048x2048 and contains 24 frames and one static frame. I used to pull my static image from the frames i generated using spriteWithSpriteFrameName. Instead I just decided to make another image file for it and create it from that. Framerate issue solved mostly...I dont understand why. I thought the texture was already in memory to begin with? Is anything wrong with my code?

circleSpriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"spritesheetbase.png"];

    //Load Note Animations
    for (int i = 0; i < 25; i++)
    {
            int x = i % 5;
     int y = i / 5;

     CCSpriteFrame* frame = [[CCSpriteFrame alloc] initWithTexture:circleSpriteSheet.textureAtlas.texture rect:CGRectMake(x * 200, y * 200, 200, 200)];
     [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFrame:frame name:[NSString stringWithFormat:@"noteFrame%d.png", i]];
     [frame release];
    }

    CCSprite *s = [CCSprite spriteWithFile:@"staticRing.png"];
    //CCSprite *s = [CCSprite spriteWithSpriteFrameName:@"noteFrame0.png"]; <--- Old way I used to create it

If someone could help I would be in your debt! I am so confused.

Arbel
  • 21
  • 1
  • I was having framerate issues. Im curious why spriteWithSpriteFrameName was causing such lag when the texture and frames are already in memory. Is something wrong with the way I am doing spritesheets? This is in the latest Cocos2d build by the way, beta3 – Arbel Oct 09 '10 at 05:42
  • I think you are just caching stuff and not using it, and then drawing something that isn't cached. I might be wrong though. –  Oct 09 '10 at 05:59
  • Those cached frames are being used elsewhere when I actually run the animation with an action during my update method. I was just adding the static frame to the cache and grabbing it from that. – Arbel Oct 09 '10 at 06:51

1 Answers1

1

I have found performance issues when building/run in debug mode. Try building/run in release mode and see if that happens to fix your frame-rate issues. This resolved a similar frame-rate issue under this post:

water effect in cocos2d

I hope it happens to solve it for you too!

Community
  • 1
  • 1
Mark7777G
  • 1,246
  • 2
  • 16
  • 26