summary refs log tree commit diff stats
path: root/Classes/ZoomFadeTransition.m
blob: da995ea0869dabf03ac2240244eb233a9686c800 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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