From ef9cab24b9ee3e25ab00d932fbab2f2a91476950 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Mon, 5 Sep 2011 12:24:04 -0400 Subject: Added zoom/fade transition to selection screen Refs #207 --- Cartographic.xcodeproj/project.pbxproj | 6 ++++ Classes/GameModeSelectionLayer.m | 12 +++++-- Classes/ZoomFadeTransition.h | 19 +++++++++++ Classes/ZoomFadeTransition.m | 60 ++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 Classes/ZoomFadeTransition.h create mode 100644 Classes/ZoomFadeTransition.m diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index 719aa26..8fd0d47 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj @@ -120,6 +120,7 @@ 6C39CFF813FD7638002B21AF /* GameModeSelectionLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */; }; 6C39D00813FD9037002B21AF /* florence.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D00713FD9037002B21AF /* florence.png */; }; 6C39D01213FD9945002B21AF /* paris.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D01113FD9945002B21AF /* paris.png */; }; + 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C4400031415080700A9E1D7 /* ZoomFadeTransition.m */; }; 6C44FFFD1413D03300A9E1D7 /* libTestFlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C88B69314119B5A0049E402 /* libTestFlight.a */; }; 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; 6C85834014055A44009EF100 /* CCNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C85833F14055A44009EF100 /* CCNotifications.m */; }; @@ -454,6 +455,8 @@ 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameModeSelectionLayer.m; sourceTree = ""; }; 6C39D00713FD9037002B21AF /* florence.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = florence.png; sourceTree = ""; }; 6C39D01113FD9945002B21AF /* paris.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paris.png; sourceTree = ""; }; + 6C4400021415080700A9E1D7 /* ZoomFadeTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomFadeTransition.h; sourceTree = ""; }; + 6C4400031415080700A9E1D7 /* ZoomFadeTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZoomFadeTransition.m; sourceTree = ""; }; 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = ""; }; 6C85833E14055A44009EF100 /* CCNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNotifications.h; sourceTree = ""; }; 6C85833F14055A44009EF100 /* CCNotifications.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCNotifications.m; sourceTree = ""; }; @@ -990,6 +993,8 @@ 6C18C3D014033DC40005AA4C /* TouchDelegatingView.h */, 6C18C3D114033DC40005AA4C /* TouchDelegatingView.m */, 6CB532581403BA4F00780A5E /* GameModeSelectionDelegate.h */, + 6C4400021415080700A9E1D7 /* ZoomFadeTransition.h */, + 6C4400031415080700A9E1D7 /* ZoomFadeTransition.m */, ); name = "Selection Screen"; sourceTree = ""; @@ -1527,6 +1532,7 @@ 6C39CFE513FC4635002B21AF /* JumpGameMode.m in Sources */, 6C85834014055A44009EF100 /* CCNotifications.m in Sources */, 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */, + 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index ef1d922..17b9d33 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m @@ -15,6 +15,7 @@ #import "ClassicGameMode.h" #import "NMPanelMenu.h" #import "JumpGameMode.h" +#import "ZoomFadeTransition.h" @implementation GameModeSelectionLayer @@ -132,15 +133,20 @@ - (void)didSelectGameMode:(GameModeSelection *)gameMode { + [pageControl removeFromSuperview]; + + CGPoint opp = [scrollView convertPoint:gameMode.position toView:[[CCDirector sharedDirector] openGLView]]; + CGPoint endPosition = ccp(0-(opp.x+158), opp.y); + if ([gameMode.name isEqual:@"Tutorial"]) { - [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; + [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[TutorialMode scene] position:endPosition]]; } else if ([gameMode.name isEqual:@"Collect"]) { - [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; + [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[ClassicGameMode scene] position:endPosition]]; } else if ([gameMode.name isEqual:@"Jump"]) { - [[CCDirector sharedDirector] replaceScene:[JumpGameMode scene]]; + [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[JumpGameMode scene] position:endPosition]]; } } diff --git a/Classes/ZoomFadeTransition.h b/Classes/ZoomFadeTransition.h new file mode 100644 index 0000000..856974f --- /dev/null +++ b/Classes/ZoomFadeTransition.h @@ -0,0 +1,19 @@ +// +// ZoomFadeTransition.h +// Cartographic +// +// Created by Starla Insigna on 9/5/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import "cocos2d.h" + +@interface ZoomFadeTransition : CCTransitionScene { + CGPoint endPosition_; + float endScale_; +} + ++ (id)transitionWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position; +- (id)initWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position; + +@end diff --git a/Classes/ZoomFadeTransition.m b/Classes/ZoomFadeTransition.m new file mode 100644 index 0000000..da995ea --- /dev/null +++ b/Classes/ZoomFadeTransition.m @@ -0,0 +1,60 @@ +// +// ZoomFadeTransition.m +// Cartographic +// +// Created by Starla Insigna on 9/5/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import "ZoomFadeTransition.h" + +@implementation ZoomFadeTransition + ++ (id)transitionWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position +{ + return [[[self alloc] initWithDuration:t scene:s position:position] autorelease]; +} + +- (id)initWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)p +{ + self = [super initWithDuration:t scene:s]; + + if (nil != self) + { + endPosition_ = ccpMult(p, 5.0f); + endScale_ = 5.0f; + } + + return self; +} + +-(void) onEnter +{ + [super onEnter]; + + [inScene_ setAnchorPoint:ccp(0.5f, 0.5f)]; + [outScene_ setAnchorPoint:ccp(0.5f, 0.5f)]; + + CCLayerColor *l = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 0)]; + [inScene_ setVisible: NO]; + [self addChild: l z:2 tag:0xFADEFADE]; + CCNode *f = [self getChildByTag:0xFADEFADE]; + + [f runAction:[CCSequence actions: + [CCDelayTime actionWithDuration:duration_/5], + [CCFadeIn actionWithDuration:duration_/3], + [CCDelayTime actionWithDuration:duration_/5], + [CCFadeOut actionWithDuration:duration_/3], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil]]; + [outScene_ runAction:[CCSpawn actions: + [CCMoveTo actionWithDuration:duration_/3 position:endPosition_], + [CCScaleTo actionWithDuration:duration_/3 scale:endScale_], + nil]]; + [inScene_ runAction: [CCSequence actions: + [CCDelayTime actionWithDuration:duration_/5*3], + [CCCallFunc actionWithTarget:self selector:@selector(hideOutShowIn)], + nil]]; +} + +@end -- cgit 1.4.1