Я делаю приложение box2d для iphone, используя cocos2d.Я пытаюсь переключить свой CCLayer с моего HelloWorldLayer на HomeScene, и я получаю сообщение об ошибке «Поток 1: Программа получила сигнал:« EXC_BAD_ACCESS »».Это дает мне эту ошибку, когда я пытаюсь вызвать [super dealloc] в моем методе dealloc для моего HelloWorldLayer.Пожалуйста помоги.Вот мои .h и .mm
@interface HelloWorldLayer : CCLayer
{
b2World *world;
Cannon *cannon1;
Cannon *cannon2;
Cannonball *cannonball1;
Cannonball *cannonball2;
float theMass;
float theMass2;
CCSprite *sunBack;
b2Vec2 cannon1Pos;
b2Vec2 cannon2Pos;
CCMenuItemSprite *pauseBut;
CCMenuItemSprite *playBut;
CCMenu *pauseMenu;
}
@property(nonatomic)b2Vec2 cannon1Pos;
@property(nonatomic)b2Vec2 cannon2Pos;
@property(nonatomic, retain)CCSprite *sunBack;
@property(nonatomic, retain)Cannon *cannon1;
@property(nonatomic, retain)Cannon *cannon2;
@property(nonatomic, retain)Cannonball *cannonball1;
@property(nonatomic, retain)Cannonball *cannonball2;
@property(nonatomic, retain)CCMenu *pauseMenu;
// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;
+(HelloWorldLayer *) sharedLayer;
-(void)createMonkeys;
-(void)restartGame;
-(void)playGame;
-(void)pauseGame;
-(CCSpriteBatchNode*)getSpriteBatch;
-(void)goToHome;
@end
Вот мои .mm, где я освобождаю
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
// in case you have something to dealloc, do it in this method
delete world;
world = NULL;
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
[cannon1 removeFromParentAndCleanup:YES];
[cannon2 removeFromParentAndCleanup:YES];
[cannonball1 removeFromParentAndCleanup:YES];
[cannonball2 removeFromParentAndCleanup:YES];
// don't forget to call "super dealloc"
[super dealloc];
}