Permalink
Browse files

Tempates & Test: CC_DIRECTOR_END()

on App Delegate Terminate the Tests & Templates calls
CC_DIRECTOR_END() if the director was initialized with
CC_DIRECTOR_INIT()
  • Loading branch information...
1 parent b5f2dff commit 280c65fe9ce81c7f316454c6e1f55e3588d4c269 @ricardoquesada ricardoquesada committed Jul 16, 2010
Showing with 173 additions and 79 deletions.
  1. +1 −0 CHANGELOG
  2. +2 −2 cocos2d-iphone.xcodeproj/project.pbxproj
  3. +8 −7 cocos2d/CCActionManager.m
  4. +1 −0 cocos2d/CCScheduler.m
  5. +1 −0 cocos2d/CCTextureCache.m
  6. +1 −1 templates/cocos2d_app/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.m
  7. +1 −1 templates/cocos2d_box2d_app/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.mm
  8. +1 −1 templates/cocos2d_chipmunk_app/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.m
  9. +6 −0 tests/ActionManagerTest.m
  10. +6 −0 tests/ActionsTest.m
  11. +6 −0 tests/AtlasTest.m
  12. +11 −4 tests/Box2dTest.mm
  13. +6 −0 tests/ChipmunkAccelTouchTest.m
  14. +6 −0 tests/ClickAndMoveTest.m
  15. +8 −2 tests/EAGLViewTest/EAGLViewTest.m
  16. +3 −1 tests/EaseActionsTest.m
  17. +4 −1 tests/EffectsAdvancedTest.m
  18. +3 −1 tests/EffectsTest.m
  19. +3 −1 tests/FontTest.m
  20. +3 −1 tests/HiResTest.m
  21. +3 −1 tests/IntervalTest.m
  22. +3 −1 tests/LayerTest.m
  23. +3 −1 tests/MenuTest.m
  24. +2 −1 tests/MotionStreakTest.m
  25. +2 −1 tests/ParallaxTest.m
  26. +2 −1 tests/ParticleTest.m
  27. +2 −1 tests/ProgressActionsTest.m
  28. +2 −1 tests/RenderTextureTest.m
  29. +2 −1 tests/RotateWorldTest.m
  30. +2 −1 tests/SceneTest.m
  31. +2 −1 tests/SchedulerTest.m
  32. +3 −1 tests/SpriteTest.m
  33. +2 −1 tests/Texture2dTest.m
  34. +3 −1 tests/TileMapTest.m
  35. +3 −1 tests/TransitionsTest.m
  36. +3 −0 tests/bugs/Bug-914/EAGLViewBugAppDelegate.h
  37. +23 −14 tests/bugs/Bug-914/EAGLViewBugAppDelegate.m
  38. +3 −6 tests/bugs/Bug-914/bugViewController.h
  39. +18 −16 tests/bugs/Bug-914/bugViewController.m
  40. +3 −1 tests/cocosnodeTest.m
  41. +3 −1 tests/drawPrimitivesTest.m
  42. +1 −1 tests/samples/HelloActions.m
  43. +1 −1 tests/samples/HelloEvents.m
  44. +1 −1 tests/samples/HelloWorld.m
View
@@ -2,6 +2,7 @@ version 0.99.5-rc XX-MMM-2010
. [NEW] Sprite: Added support for Zwoptex v1.0 (issue #913)
. [FIX] Particles: Built-in particles use QuadParticles when compiled in ARMv7,
and PointParticles when compiled in ARMv6
+ . [FIX] Templates & Tests: call CC_DIRECTOR_END() on AppDelegate Terminate
version 0.99.4 - 14-Jul-2010
. [NEW] CocosDenshion: switching between background and foreground music (issue #928)
@@ -5680,10 +5680,10 @@
506881E70E9575E100F943E5 /* AtlasTest.m */,
504227120FC0B96E00B992F7 /* Box2dTest.h */,
504227130FC0B96E00B992F7 /* Box2dTest.mm */,
- 506C77E50E01524200B48100 /* ClickAndMoveTest.h */,
- 506C77E60E01524200B48100 /* ClickAndMoveTest.m */,
50B2C5EB0E100F8800AE9530 /* ChipmunkAccelTouchTest.h */,
50B2C5EC0E100F8800AE9530 /* ChipmunkAccelTouchTest.m */,
+ 506C77E50E01524200B48100 /* ClickAndMoveTest.h */,
+ 506C77E60E01524200B48100 /* ClickAndMoveTest.m */,
5061440B0E589A7B003CCDB7 /* cocosnodeTest.h */,
5061440C0E589A7B003CCDB7 /* cocosnodeTest.m */,
5019457F0F964CFD0059CE7C /* drawPrimitivesTest.h */,
@@ -33,7 +33,7 @@
//
// singleton stuff
//
-static CCActionManager *_sharedManager = nil;
+static CCActionManager *sharedManager_ = nil;
@interface CCActionManager (Private)
-(void) removeActionAtIndex:(NSUInteger)index hashElement:(tHashElement*)element;
@@ -47,22 +47,23 @@ @implementation CCActionManager
#pragma mark ActionManager - init
+ (CCActionManager *)sharedManager
{
- if (!_sharedManager)
- _sharedManager = [[self alloc] init];
+ if (!sharedManager_)
+ sharedManager_ = [[self alloc] init];
- return _sharedManager;
+ return sharedManager_;
}
+(id)alloc
{
- NSAssert(_sharedManager == nil, @"Attempted to allocate a second instance of a singleton.");
+ NSAssert(sharedManager_ == nil, @"Attempted to allocate a second instance of a singleton.");
return [super alloc];
}
+(void)purgeSharedManager
{
[[CCScheduler sharedScheduler] unscheduleUpdateForTarget:self];
- [_sharedManager release];
+ [sharedManager_ release];
+ sharedManager_ = nil;
}
-(id) init
@@ -81,7 +82,7 @@ - (void) dealloc
[self removeAllActions];
- _sharedManager = nil;
+ sharedManager_ = nil;
[super dealloc];
}
@@ -178,6 +178,7 @@ +(id)alloc
+(void)purgeSharedScheduler
{
[sharedScheduler release];
+ sharedScheduler = nil;
}
- (id) init
@@ -101,6 +101,7 @@ +(id)alloc
+(void)purgeSharedTextureCache
{
[sharedTextureCache release];
+ sharedTextureCache = nil;
}
-(id) init
@@ -75,7 +75,7 @@ -(void) applicationWillEnterForeground:(UIApplication*)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
@@ -74,7 +74,7 @@ -(void) applicationWillEnterForeground:(UIApplication*)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
@@ -75,7 +75,7 @@ -(void) applicationWillEnterForeground:(UIApplication*)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
@@ -395,6 +395,12 @@ -(void) applicationDidBecomeActive:(UIApplication *)application
[[CCDirector sharedDirector] resume];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to background
-(void) applicationDidEnterBackground:(UIApplication*)application
{
View
@@ -1053,6 +1053,12 @@ -(void) applicationDidBecomeActive:(UIApplication *)application
[[CCDirector sharedDirector] resume];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to background
-(void) applicationDidEnterBackground:(UIApplication*)application
{
View
@@ -749,6 +749,12 @@ -(void) applicationDidEnterBackground:(UIApplication*)application
[[CCDirector sharedDirector] stopAnimation];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to foreground
-(void) applicationWillEnterForeground:(UIApplication*)application
{
View
@@ -97,7 +97,7 @@ -(id) init
[label setColor:ccc3(0,0,255)];
label.position = ccp( screenSize.width/2, screenSize.height-50);
- [self schedule: @selector(tick:)];
+ [self scheduleUpdate];
}
return self;
}
@@ -108,6 +108,7 @@ -(void) dealloc
world = NULL;
delete m_debugDraw;
+ m_debugDraw = NULL;
[super dealloc];
}
@@ -138,7 +139,7 @@ -(void) addNewSpriteWithCoords:(CGPoint)p
//just randomly picking one of the images
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
- CCSprite *sprite = [sheet createSpriteWithRect:CGRectMake(32 * idx,32 * idy,32,32)];
+ CCSprite *sprite = [CCSprite spriteWithTexture:[sheet texture] rect:CGRectMake(32 * idx,32 * idy,32,32)];
[sheet addChild:sprite];
sprite.position = ccp( p.x, p.y);
@@ -165,7 +166,7 @@ -(void) addNewSpriteWithCoords:(CGPoint)p
--(void) tick: (ccTime) dt
+-(void) update: (ccTime) dt
{
//It is recommended that a fixed time step is used with Box2D for stability
//of the simulation, however, we are using a variable time step here.
@@ -266,7 +267,7 @@ - (void) applicationDidFinishLaunching:(UIApplication*)application
// add layer
CCScene *scene = [CCScene node];
- id box2dLayer = [[Box2DTestLayer alloc] init];
+ id box2dLayer = [Box2DTestLayer node];
[scene addChild:box2dLayer z:0];
[director runWithScene: scene];
@@ -290,6 +291,12 @@ -(void) applicationDidBecomeActive:(UIApplication *)application
[[CCDirector sharedDirector] resume];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to background
-(void) applicationDidEnterBackground:(UIApplication*)application
{
@@ -239,6 +239,12 @@ -(void) applicationDidBecomeActive:(UIApplication *)application
[[CCDirector sharedDirector] resume];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to background
-(void) applicationDidEnterBackground:(UIApplication*)application
{
@@ -132,6 +132,12 @@ -(void) applicationDidBecomeActive:(UIApplication *)application
[[CCDirector sharedDirector] resume];
}
+// application will be killed
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ CC_DIRECTOR_END();
+}
+
// sent to background
-(void) applicationDidEnterBackground:(UIApplication*)application
{
@@ -100,14 +100,20 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CCDirector *director = [CCDirector sharedDirector];
+ [[director openGLView] removeFromSuperview];
+ [director end];
+
+ // release glView here, else it won't be dealloced
+ [glView_ release];
+ glView_ = nil;
}
#pragma mark -
#pragma mark Init
-(void) dealloc
{
- [glView_ release];
+// [glView_ release];
[window_ release];
[super dealloc];
}
@@ -758,11 +758,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memroy
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
@@ -430,7 +430,10 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CCDirector *director = [CCDirector sharedDirector];
+
+ [[director openGLView] removeFromSuperview];
+ [director end];
}
// purge memroy
View
@@ -530,11 +530,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
View
@@ -196,11 +196,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
View
@@ -275,7 +275,9 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CCDirector *director = [CCDirector sharedDirector];
+ [[director openGLView] removeFromSuperview];
+ [director end];
}
// purge memory
@@ -187,11 +187,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
View
@@ -335,11 +335,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
View
@@ -473,11 +473,13 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
+
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
@@ -258,9 +258,10 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
// purge memory
@@ -341,9 +341,10 @@ -(void) applicationWillEnterForeground:(UIApplication*)application
[[CCDirector sharedDirector] startAnimation];
}
+// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
- [[CCDirector sharedDirector] end];
+ CC_DIRECTOR_END();
}
// purge memory
Oops, something went wrong.

0 comments on commit 280c65f

Please sign in to comment.