0

It is a bit simple problem but i could not figure it out.

1-> Application Starts (with MainMenu scene)

2-> Start (Sub levels scene is replaced)

3-> Select First Level (Level1Scene is replaced. Game started.)

4-> Get back to main menu. (MainMenu Scene is replaced)

5-> Start (Sub levels scene is replaced)

6-> Select First Level

7-> Crashes.

box(32842,0x3f5c9d98) malloc: * error for object 0x4bed44: incorrect checksum for freed object - object was probably modified after being freed. * set a breakpoint in malloc_error_break to debug

When i replace scenes a to b, is a released?

As far as i know, only pushScene keeps scene at memory.

+(CCScene *) scene {

    CCScene *scene = [CCScene node];

    HelloWorldLayer *layer = [HelloWorldLayer node];

    [scene addChild: layer];

    return scene;
}

Scene and layer are autorelease objects. Must be released when replaceScene is called. (If previous scene is released while replacing scenes.)

iPhoneProcessor
  • 4,980
  • 6
  • 27
  • 49
Quaso
  • 373
  • 1
  • 6
  • 18
  • 1
    Only first time use pushScene, then use replaceScene - – Guru Mar 21 '13 at 11:36
  • I'm still having the same problem. When i get back to MainMenu scene, Level1Scene must be released. Why i getting malloc: *** error for object 0x4da934: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug when second time replacing game scene? – Quaso Mar 22 '13 at 07:59

1 Answers1

0

I have solved this problem. Its weird but works.

I had a class that subclass of CCSprite called Collectable. It has cousing crash when second time replacing the scene that has Collectable object. I converted it to CCNode and its works now.

Maybe it helps someone.

Quaso
  • 373
  • 1
  • 6
  • 18