summary refs log tree commit diff stats
path: root/libs/cocos2d/CCTransitionPageTurn.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
committerStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
commit9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch)
tree5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/CCTransitionPageTurn.m
downloadcartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/CCTransitionPageTurn.m')
-rwxr-xr-xlibs/cocos2d/CCTransitionPageTurn.m117
1 files changed, 117 insertions, 0 deletions
diff --git a/libs/cocos2d/CCTransitionPageTurn.m b/libs/cocos2d/CCTransitionPageTurn.m new file mode 100755 index 0000000..bff43a7 --- /dev/null +++ b/libs/cocos2d/CCTransitionPageTurn.m
@@ -0,0 +1,117 @@
1/*
2 * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 *
4 * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 */
25
26
27#import "CCTransitionPageTurn.h"
28#import "CCActionPageTurn3D.h"
29#import "CCDirector.h"
30
31@implementation CCTransitionPageTurn
32
33/** creates a base transition with duration and incoming scene */
34+(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back
35{
36 return [[[self alloc] initWithDuration:t scene:s backwards:back] autorelease];
37}
38
39/** initializes a transition with duration and incoming scene */
40-(id) initWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back
41{
42 // XXX: needed before [super init]
43 back_ = back;
44
45 if( ( self = [super initWithDuration:t scene:s] ) )
46 {
47 // do something
48 }
49 return self;
50}
51
52-(void) sceneOrder
53{
54 inSceneOnTop_ = back_;
55}
56
57//
58-(void) onEnter
59{
60 [super onEnter];
61
62 CGSize s = [[CCDirector sharedDirector] winSize];
63 int x, y;
64 if( s.width > s.height)
65 {
66 x = 16;
67 y = 12;
68 }
69 else
70 {
71 x = 12;
72 y = 16;
73 }
74
75 id action = [self actionWithSize:ccg(x,y)];
76
77 if(! back_ )
78 {
79 [outScene_ runAction: [CCSequence actions:
80 action,
81 [CCCallFunc actionWithTarget:self selector:@selector(finish)],
82 [CCStopGrid action],
83 nil]
84 ];
85 }
86 else
87 {
88 // to prevent initial flicker
89 inScene_.visible = NO;
90 [inScene_ runAction: [CCSequence actions:
91 [CCShow action],
92 action,
93 [CCCallFunc actionWithTarget:self selector:@selector(finish)],
94 [CCStopGrid action],
95 nil]
96 ];
97 }
98
99}
100
101-(CCActionInterval*) actionWithSize: (ccGridSize) v
102{
103 if( back_ )
104 {
105 // Get hold of the PageTurn3DAction
106 return [CCReverseTime actionWithAction:
107 [CCPageTurn3D actionWithSize:v duration:duration_]];
108 }
109 else
110 {
111 // Get hold of the PageTurn3DAction
112 return [CCPageTurn3D actionWithSize:v duration:duration_];
113 }
114}
115
116@end
117