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 --- Classes/GameModeSelectionLayer.m | 12 ++++++-- Classes/ZoomFadeTransition.h | 19 +++++++++++++ Classes/ZoomFadeTransition.m | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 Classes/ZoomFadeTransition.h create mode 100644 Classes/ZoomFadeTransition.m (limited to 'Classes') 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