iphone sdk 4.1内存泄漏:可能是场景替换问题(cocos2d)

时间:2010-10-13 05:11:45

标签: memory-leaks cocos2d-iphone ios4 scene

我使用调度程序从场景返回到主菜单。除菜单外,场景页面中没有任何内容。但是当我浏览场景时,场景不会解除分配并且内存泄漏会增加。所以应用程序没有关闭(当使用iphone / ipod按钮关闭时保持在后台运行)但是崩溃。

希望你们中的一些人面对并解决了这类问题。期待从这里出来的方法。

以下是我的班级来源 -

委托者

@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

泄漏屏幕截图 -

alt text

编辑:

我已经删除了转换 - 仍然没有泄漏,应用程序没有关闭,正如我上面所解释的那样 - 这是屏幕截图

alt text

1 个答案:

答案 0 :(得分:0)

哦!内存泄漏问题解决了。现在还有一个问题 - 按下iPhone Home按钮(唯一的按钮)后,App在后台运行。

如何解决内存泄漏问题

这很简单但很棘手。它是关于触摸调度程序和调度程序。

Unscheduling: 的 如果从(并且仅)计划选择器内切换场景,则无需取消计划该选择器。 但是如果您从预定选择器外部切换场景或者有多个预定选择器,则必须在切换之前取消预定。

从Touch Dispatcher中移除 (如果有) 从Touch Dispatcher

中删除当前场景

在替换当前场景之前完成了上述两个操作并且工作正常。每个dealloc都正确调用:)