2010-10-13 54 views
1

我已經使用調度器從場景返回到主菜單。除了菜單,場景頁面中沒有任何內容。但是,在我瀏覽場景時,場景不會釋放並且內存泄漏增加。所以應用程序不關閉(當關閉使用iphone/ipod按鈕時保持在後臺運行)但崩潰。iphone sdk 4.1內存泄漏:可能是場景替換問題(cocos2d)

希望你們中的一些人面臨和解決這類問題。期待從這裏出來的一種方式。

這裏是我的類來源 -

委託者

@implementation BubbleWordAppDelegate 

@synthesize window; 

- (void) applicationDidFinishLaunching:(UIApplication*)application 
{ 
    CC_DIRECTOR_INIT(); 

    // Obtain the shared director in order to... 
    CCDirector *director = [CCDirector sharedDirector]; 

    // Sets landscape mode 
    //[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; 

    // Turn on display FPS 
    [director setDisplayFPS:NO]; 

    // Turn on multiple touches 
    EAGLView *view = [director openGLView]; 
    [view setMultipleTouchEnabled:YES]; 

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images 
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 
    // You can change anytime. 
    [CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];  

// [[CCDirector sharedDirector] runWithScene: [MainGameLayer scene]]; 
    [[CCDirector sharedDirector] runWithScene: [MenuScene node]]; 

} 

- (void)applicationWillResignActive:(UIApplication *)application { 
    [[CCDirector sharedDirector] pause]; 
} 

- (void)applicationDidBecomeActive:(UIApplication *)application { 
    [[CCDirector sharedDirector] resume]; 
} 

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 
    [[CCTextureCache sharedTextureCache] removeUnusedTextures]; 
} 

- (void)applicationWillTerminate:(UIApplication *)application { 
    [[CCDirector sharedDirector] end]; 
} 

- (void)applicationSignificantTimeChange:(UIApplication *)application { 
    [[CCDirector sharedDirector] setNextDeltaTimeZero:YES]; 
} 

- (void)dealloc { 
    [[CCDirector sharedDirector] release]; 
    [window release]; 
    [super dealloc]; 
} 

@end 

菜單場景

#import "cocos2d.h" 
#import "MenuScene.h" 
#import "SettingsScene.h" 
#import "AboutScene.h" 
//#import "MainGameLayer.h" 
#import "ErgoTransitions.h" 

@implementation MenuScene 

- (id) init 
{ 
    self = [super init]; 
    if (self != nil) { 
//  CCMenuItem *menuItem1 = [CCMenuItemFont itemFromString:@"Play" target:self selector:@selector(onPlay:)]; 
     CCMenuItem *menuItem2 = [CCMenuItemFont itemFromString:@"Settings" target:self selector:@selector(onSettings:)]; 
     CCMenuItem *menuItem3 = [CCMenuItemFont itemFromString:@"About" target:self selector:@selector(onAbout:)]; 

//  CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2, menuItem3, nil]; 
     CCMenu *menu = [CCMenu menuWithItems: menuItem2, menuItem3, nil]; 
     [menu alignItemsVertically]; 
     [self addChild:menu]; 
    } 
    return self; 
} 
/* 
- (void)onPlay:(id)sender 
{ 
    NSLog(@"on play"); 
    [[CCDirector sharedDirector] replaceScene: [ErgoTransitions randomTransition:[MainGameLayer node]]]; 

} 
*/ 

- (void)onSettings:(id)sender 
{ 
    NSLog(@"on settings"); 
    [[CCDirector sharedDirector] replaceScene: [ErgoTransitions PageTransitionForward:[SettingsScene node]]]; 
// [[CCDirector sharedDirector] replaceScene: [ErgoTransitions randomTransition:[SettingsScene node]]]; 
} 

- (void)onAbout:(id)sender 
{ 
    NSLog(@"on about"); 
    [[CCDirector sharedDirector] replaceScene: [ErgoTransitions PageTransitionForward:[AboutScene node]]]; 
// [[CCDirector sharedDirector] replaceScene: [ErgoTransitions randomTransition:[AboutScene node]]]; 
} 


@end 

關於場景

#import "cocos2d.h" 
#import "AboutScene.h" 
#import "MenuScene.h" 
#import "ErgoTransitions.h" 

@implementation AboutScene 

- (id) init 
{ 
    self = [super init]; 
    if (self != nil) { 
     CGSize winSize= [[CCDirector sharedDirector] winSize]; 

     CCSprite *bg = [CCSprite spriteWithFile:@"background2.png"]; 
     bg.position = ccp(winSize.width/2,winSize.height/2); 
     [self addChild:bg]; 

     CCLabel *label = [CCLabel labelWithString:@"about scene" fontName:@"Arial" fontSize:20]; 
     label.position = ccp(winSize.width/2,winSize.height/2); 
     [self addChild:label]; 

     [self schedule:@selector(onEnd:) interval:2]; 
    } 
    return self; 
} 

- (void)onEnd:(ccTime)dt 
{ 
    [[CCDirector sharedDirector] replaceScene: [ErgoTransitions PageTransitionBackward:[MenuScene node]]]; 
// [[CCDirector sharedDirector] replaceScene: [ErgoTransitions randomTransition:[MenuScene node]]]; 
} 


@end 

事務類(來自的cocos2d TestTransitions)

#import "cocos2d.h" 
#import "ErgoTransitions.h" 


#define TRANSITION_DURATION (1.2f) 

//static int sceneIdx=0; 
static NSString *transitions[] = { 
    @"CCJumpZoomTransition", 
    @"CCCrossFadeTransition", 
    @"PageTransitionForward", 
    @"PageTransitionBackward", 
    @"CCFadeTRTransition", 
    @"CCFadeBLTransition", 
    @"CCFadeUpTransition", 
    @"CCFadeDownTransition", 
    @"CCTurnOffTilesTransition", 
    @"CCSplitRowsTransition", 
    @"CCSplitColsTransition", 
    @"CCFadeTransition", 
    @"FadeWhiteTransition", 
    @"FlipXLeftOver", 
    @"FlipXRightOver", 
    @"FlipYUpOver", 
    @"FlipYDownOver", 
    @"FlipAngularLeftOver", 
    @"FlipAngularRightOver", 
    @"ZoomFlipXLeftOver", 
    @"ZoomFlipXRightOver", 
    @"ZoomFlipYUpOver", 
    @"ZoomFlipYDownOver", 
    @"ZoomFlipAngularLeftOver", 
    @"ZoomFlipAngularRightOver", 
    @"CCShrinkGrowTransition", 
    @"CCRotoZoomTransition", 
    @"CCMoveInLTransition", 
    @"CCMoveInRTransition", 
    @"CCMoveInTTransition", 
    @"CCMoveInBTransition", 
    @"CCSlideInLTransition", 
    @"CCSlideInRTransition", 
    @"CCSlideInTTransition", 
    @"CCSlideInBTransition", 
}; 


@interface FadeWhiteTransition : CCFadeTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipXLeftOver : CCFlipXTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipXRightOver : CCFlipXTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipYUpOver : CCFlipYTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipYDownOver : CCFlipYTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipAngularLeftOver : CCFlipAngularTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface FlipAngularRightOver : CCFlipAngularTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipXLeftOver : CCZoomFlipXTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipXRightOver : CCZoomFlipXTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipYUpOver : CCZoomFlipYTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipYDownOver : CCZoomFlipYTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipAngularLeftOver : CCZoomFlipAngularTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface ZoomFlipAngularRightOver : CCZoomFlipAngularTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface PageTransitionForward : CCPageTurnTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 
@interface PageTransitionBackward : CCPageTurnTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s; 
@end 


@implementation FlipXLeftOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationLeftOver]; 
} 
@end 
@implementation FadeWhiteTransition 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s withColor:ccWHITE]; 
} 
@end 

@implementation FlipXRightOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationRightOver]; 
} 
@end 
@implementation FlipYUpOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationUpOver]; 
} 
@end 
@implementation FlipYDownOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationDownOver]; 
} 
@end 
@implementation FlipAngularLeftOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationLeftOver]; 
} 
@end 
@implementation FlipAngularRightOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationRightOver]; 
} 
@end 
@implementation ZoomFlipXLeftOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationLeftOver]; 
} 
@end 
@implementation ZoomFlipXRightOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationRightOver]; 
} 
@end 
@implementation ZoomFlipYUpOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationUpOver]; 
} 
@end 
@implementation ZoomFlipYDownOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationDownOver]; 
} 
@end 
@implementation ZoomFlipAngularLeftOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationLeftOver]; 
} 
@end 
@implementation ZoomFlipAngularRightOver 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s orientation:kOrientationRightOver]; 
} 
@end 

@implementation PageTransitionForward 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s backwards:NO]; 
} 
@end 

@implementation PageTransitionBackward 
+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s { 
    return [self transitionWithDuration:t scene:s backwards:YES]; 
} 
@end 

@implementation ErgoTransitions 

+(id) transitionWith:(NSString *) transitionName scene:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(transitionName); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id) randomTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    short selectedTransition = [ErgoTransitions getRandomNumber:0 to:((short)sizeof(transitions)/(short)sizeof(transitions[0]))]; 
    Class transitionClass = NSClassFromString(transitions[selectedTransition]); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id) JumpZoomTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCJumpZoomTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)CrossFadeTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCCrossFadeTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)PageTransitionForward:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"PageTransitionForward"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)PageTransitionBackward:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"PageTransitionBackward"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeTRTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCFadeTRTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeBLTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCFadeBLTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeUpTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCFadeUpTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeDownTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCFadeDownTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)TurnOffTilesTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCTurnOffTilesTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)SplitRowsTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSplitRowsTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)SplitColsTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSplitColsTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCFadeTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FadeWhiteTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FadeWhiteTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipXLeftOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipXLeftOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipXRightOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipXRightOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipYUpOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipYUpOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipYDownOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipYDownOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipAngularLeftOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipAngularLeftOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)FlipAngularRightOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"FlipAngularRightOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipXLeftOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipXLeftOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipXRightOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipXRightOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipYUpOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipYUpOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipYDownOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipYDownOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipAngularLeftOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipAngularLeftOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ZoomFlipAngularRightOver:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"ZoomFlipAngularRightOver"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)ShrinkGrowTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCShrinkGrowTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)RotoZoomTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCRotoZoomTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)MoveInLTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCMoveInLTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)MoveInRTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCMoveInRTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)MoveInTTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCMoveInTTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)MoveInBTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCMoveInBTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)SlideInLTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSlideInLTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id)SlideInRTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSlideInRTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id) SlideInTTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSlideInTTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
+(id) SlideInBTransition:(CCScene*) scene withDuration:(ccTime) duration 
{  
    Class transitionClass = NSClassFromString(@"CCSlideInBTransition"); 
    return [transitionClass transitionWithDuration:duration scene:scene]; 
} 
//------ OverLoaded without Direction 
+(id) transitionWith:(NSString *) transitionName scene:(CCScene*) scene 
{  
    return [ErgoTransitions transitionWith:transitionName scene:scene withDuration:TRANSITION_DURATION]; 
} 
+(id) randomTransition:(CCScene*) scene 
{  
    return [ErgoTransitions randomTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id) JumpZoomTransition:(CCScene*) scene 
{  
    return [ErgoTransitions JumpZoomTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)CrossFadeTransition:(CCScene*) scene 
{  
    return [ErgoTransitions CrossFadeTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)PageTransitionForward:(CCScene*) scene 
{  
    return [ErgoTransitions PageTransitionForward:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)PageTransitionBackward:(CCScene*) scene 
{  
    return [ErgoTransitions PageTransitionBackward:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeTRTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeTRTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeBLTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeBLTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeUpTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeUpTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeDownTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeDownTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)TurnOffTilesTransition:(CCScene*) scene 
{  
    return [ErgoTransitions TurnOffTilesTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)SplitRowsTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SplitRowsTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)SplitColsTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SplitColsTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FadeWhiteTransition:(CCScene*) scene 
{  
    return [ErgoTransitions FadeWhiteTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipXLeftOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipXLeftOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipXRightOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipXRightOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipYUpOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipYUpOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipYDownOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipYDownOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipAngularLeftOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipAngularLeftOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)FlipAngularRightOver:(CCScene*) scene 
{  
    return [ErgoTransitions FlipAngularRightOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipXLeftOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipXLeftOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipXRightOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipXRightOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipYUpOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipYUpOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipYDownOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipYDownOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipAngularLeftOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipAngularLeftOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ZoomFlipAngularRightOver:(CCScene*) scene 
{  
    return [ErgoTransitions ZoomFlipAngularRightOver:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)ShrinkGrowTransition:(CCScene*) scene 
{  
    return [ErgoTransitions ShrinkGrowTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)RotoZoomTransition:(CCScene*) scene 
{  
    return [ErgoTransitions RotoZoomTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)MoveInLTransition:(CCScene*) scene 
{  
    return [ErgoTransitions MoveInLTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)MoveInRTransition:(CCScene*) scene 
{  
    return [ErgoTransitions MoveInRTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)MoveInTTransition:(CCScene*) scene 
{  
    return [ErgoTransitions MoveInTTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)MoveInBTransition:(CCScene*) scene 
{  
    return [ErgoTransitions MoveInBTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)SlideInLTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SlideInLTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id)SlideInRTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SlideInRTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id) SlideInTTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SlideInTTransition:scene withDuration:TRANSITION_DURATION]; 
} 
+(id) SlideInBTransition:(CCScene*) scene 
{  
    return [ErgoTransitions SlideInBTransition:scene withDuration:TRANSITION_DURATION]; 
} 

+(short)getRandomNumber:(short)from to:(short)to 
{ 

    return (short)from + arc4random() % (to-from+1); 

} 

@end 

泄漏screenshot-

alt text

編輯:

我已刪除transition-仍泄漏和應用程序不打烊,因爲我已經上文 解釋這裏是屏幕截圖

alt text

回答

0

哦!內存泄漏得到解決。現在只剩下一個問題了 - 通過按下iPhone Home按鈕(唯一的按鈕)關閉它後,App會在後臺運行。

如何內存泄漏解決:

這很簡單,但棘手。它是關於觸摸調度程序和調度程序。

Unscheduling: 如果從(只)計劃的選擇中切換的場景,那麼你不必取消預定該選擇。 但是,如果您從預定選擇器外部切換場景,或者有多個預定選擇器,則必須在切換之前取消調度。從觸摸調度(如果有的話) 從觸摸調度

刪除當前場景

刪除

做兩個以上的取代當前場景之前,它工作正常。每個dealloc調用正確:)