iphone sdk 4.1内存泄漏:可能是场景替换问题(cocos2d)
我已经使用调度程序从场景返回到主菜单。场景页面中除了菜单之外没有任何内容。但当我浏览场景时,场景不会重新分配,并且内存泄漏会增加。因此应用程序没有关闭(使用 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
关于场景< /strong>
#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
泄漏截图-
编辑:
我已经删除了转换 - 仍然泄漏并且应用程序没有关闭,正如我上面所解释的 - 这是屏幕截图
I have used scheduler to return from a scene to the main menu. There is nothing in the scene page except menu. But scenes are not deallocating and memory leakage increasing as i navigate through the scenes. So application is not closing(kept running in background when close using iphone/ipod button) but crashing.
Hope some of you faced and resolved this type of problem.Expecting a way to out from here.
Here are my class sources-
Delegator
@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
Menu Scene
#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
About Scene
#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
Transaction Class (from 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
Leakage screenshot-
EDITED:
I have removed transition- still leakage and app is not closing as i have explained above-
here is the screen shot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦!内存泄漏已解决。现在剩下一个问题 - 按 iPhone Home 按钮(唯一的按钮)关闭应用程序后,应用程序在后台运行。
如何解决内存泄漏:
这很简单,但很棘手。这是关于触摸调度程序和调度程序的。
取消安排:
如果您从(且唯一)计划选择器内切换场景,则无需取消计划该选择器。
但是,如果您从计划选择器之外切换场景,或者有多个计划选择器,则必须在切换之前取消计划。
从 Touch Dispatcher 中删除(如果有)
从触摸调度程序中删除当前场景
在替换当前场景之前执行了上述两项操作,并且工作正常。每个 dealloc 都正确调用:)
oh! memory leakage is solved. Now one problem left- App runs in background after closing it by pressing iPhone Home button( the only button).
How memory leakage is solved:
It was simple but tricky. it was about touch dispatcher and scheduler.
Unscheduling:
If you switch scene from within a(and only) scheduled selector, then you need not to unschedule that selector.
But if you switch scene from outside of scheduled selector or there is more than one scheduled selector then you must unschedule before switching.
Remove from Touch Dispatcher(if any)
Remove current scene from Touch Dispatcher
did both of above before replacing current scene and it works fine. Every dealloc is calling properly :)