diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-09-05 12:24:04 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-09-05 12:24:04 -0400 |
commit | ef9cab24b9ee3e25ab00d932fbab2f2a91476950 (patch) | |
tree | 64181097c4ba8f5e2fd7ad5efcebac37adff83c5 /Classes | |
parent | c505b38ac0ad593ee7c4e56895a06a69878a88d3 (diff) | |
download | cartcollect-ef9cab24b9ee3e25ab00d932fbab2f2a91476950.tar.gz cartcollect-ef9cab24b9ee3e25ab00d932fbab2f2a91476950.tar.bz2 cartcollect-ef9cab24b9ee3e25ab00d932fbab2f2a91476950.zip |
Added zoom/fade transition to selection screen
Refs #207
Diffstat (limited to 'Classes')
-rw-r--r-- | Classes/GameModeSelectionLayer.m | 12 | ||||
-rw-r--r-- | Classes/ZoomFadeTransition.h | 19 | ||||
-rw-r--r-- | Classes/ZoomFadeTransition.m | 60 |
3 files changed, 88 insertions, 3 deletions
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 @@ | |||
15 | #import "ClassicGameMode.h" | 15 | #import "ClassicGameMode.h" |
16 | #import "NMPanelMenu.h" | 16 | #import "NMPanelMenu.h" |
17 | #import "JumpGameMode.h" | 17 | #import "JumpGameMode.h" |
18 | #import "ZoomFadeTransition.h" | ||
18 | 19 | ||
19 | @implementation GameModeSelectionLayer | 20 | @implementation GameModeSelectionLayer |
20 | 21 | ||
@@ -132,15 +133,20 @@ | |||
132 | 133 | ||
133 | - (void)didSelectGameMode:(GameModeSelection *)gameMode | 134 | - (void)didSelectGameMode:(GameModeSelection *)gameMode |
134 | { | 135 | { |
136 | [pageControl removeFromSuperview]; | ||
137 | |||
138 | CGPoint opp = [scrollView convertPoint:gameMode.position toView:[[CCDirector sharedDirector] openGLView]]; | ||
139 | CGPoint endPosition = ccp(0-(opp.x+158), opp.y); | ||
140 | |||
135 | if ([gameMode.name isEqual:@"Tutorial"]) | 141 | if ([gameMode.name isEqual:@"Tutorial"]) |
136 | { | 142 | { |
137 | [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; | 143 | [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[TutorialMode scene] position:endPosition]]; |
138 | } else if ([gameMode.name isEqual:@"Collect"]) | 144 | } else if ([gameMode.name isEqual:@"Collect"]) |
139 | { | 145 | { |
140 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; | 146 | [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[ClassicGameMode scene] position:endPosition]]; |
141 | } else if ([gameMode.name isEqual:@"Jump"]) | 147 | } else if ([gameMode.name isEqual:@"Jump"]) |
142 | { | 148 | { |
143 | [[CCDirector sharedDirector] replaceScene:[JumpGameMode scene]]; | 149 | [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[JumpGameMode scene] position:endPosition]]; |
144 | } | 150 | } |
145 | } | 151 | } |
146 | 152 | ||
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 @@ | |||
1 | // | ||
2 | // ZoomFadeTransition.h | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 9/5/11. | ||
6 | // Copyright (c) 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "cocos2d.h" | ||
10 | |||
11 | @interface ZoomFadeTransition : CCTransitionScene { | ||
12 | CGPoint endPosition_; | ||
13 | float endScale_; | ||
14 | } | ||
15 | |||
16 | + (id)transitionWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position; | ||
17 | - (id)initWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position; | ||
18 | |||
19 | @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 @@ | |||
1 | // | ||
2 | // ZoomFadeTransition.m | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 9/5/11. | ||
6 | // Copyright (c) 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "ZoomFadeTransition.h" | ||
10 | |||
11 | @implementation ZoomFadeTransition | ||
12 | |||
13 | + (id)transitionWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)position | ||
14 | { | ||
15 | return [[[self alloc] initWithDuration:t scene:s position:position] autorelease]; | ||
16 | } | ||
17 | |||
18 | - (id)initWithDuration:(ccTime)t scene:(CCScene *)s position:(CGPoint)p | ||
19 | { | ||
20 | self = [super initWithDuration:t scene:s]; | ||
21 | |||
22 | if (nil != self) | ||
23 | { | ||
24 | endPosition_ = ccpMult(p, 5.0f); | ||
25 | endScale_ = 5.0f; | ||
26 | } | ||
27 | |||
28 | return self; | ||
29 | } | ||
30 | |||
31 | -(void) onEnter | ||
32 | { | ||
33 | [super onEnter]; | ||
34 | |||
35 | [inScene_ setAnchorPoint:ccp(0.5f, 0.5f)]; | ||
36 | [outScene_ setAnchorPoint:ccp(0.5f, 0.5f)]; | ||
37 | |||
38 | CCLayerColor *l = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 0)]; | ||
39 | [inScene_ setVisible: NO]; | ||
40 | [self addChild: l z:2 tag:0xFADEFADE]; | ||
41 | CCNode *f = [self getChildByTag:0xFADEFADE]; | ||
42 | |||
43 | [f runAction:[CCSequence actions: | ||
44 | [CCDelayTime actionWithDuration:duration_/5], | ||
45 | [CCFadeIn actionWithDuration:duration_/3], | ||
46 | [CCDelayTime actionWithDuration:duration_/5], | ||
47 | [CCFadeOut actionWithDuration:duration_/3], | ||
48 | [CCCallFunc actionWithTarget:self selector:@selector(finish)], | ||
49 | nil]]; | ||
50 | [outScene_ runAction:[CCSpawn actions: | ||
51 | [CCMoveTo actionWithDuration:duration_/3 position:endPosition_], | ||
52 | [CCScaleTo actionWithDuration:duration_/3 scale:endScale_], | ||
53 | nil]]; | ||
54 | [inScene_ runAction: [CCSequence actions: | ||
55 | [CCDelayTime actionWithDuration:duration_/5*3], | ||
56 | [CCCallFunc actionWithTarget:self selector:@selector(hideOutShowIn)], | ||
57 | nil]]; | ||
58 | } | ||
59 | |||
60 | @end | ||