//
// HelloWorldLayer.m
//
// Import the interfaces
#import "HelloWorldLayer.h"
#import "DateSceneLayer.h"
#define TRANSITION_DURATION 1.0f
#define TRANSITION_MAX 29
static int transitionIndex=0;
// HelloWorldLayer implementation
@implementation HelloWorldLayer
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
// on "init" you need to initialize your instance
-(void)updateText
{
[self unschedule:@selector(updateText)];
// create and initialize a Label
// ask director the the window size
CGSize size = [[CCDirector sharedDirector] winSize];
CCLabelTTF* trasitionlabel=nil;
switch (transitionIndex)
{
case 0:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionRotoZoom" fontName:@"AppleGothic" fontSize:32];
break;
case 1:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionJumpZoom" fontName:@"AppleGothic" fontSize:32];
break;
case 2:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionMoveInL" fontName:@"AppleGothic" fontSize:32];
break;
case 3:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionMoveInR" fontName:@"AppleGothic" fontSize:32];
break;
case 4:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionMoveInT" fontName:@"AppleGothic" fontSize:32];
break;
case 5:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionMoveInB" fontName:@"AppleGothic" fontSize:32];
break;
case 6:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSlideInL" fontName:@"AppleGothic" fontSize:32];
break;
case 7:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSlideInR" fontName:@"AppleGothic" fontSize:32];
break;
case 8:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSlideInB" fontName:@"AppleGothic" fontSize:32];
break;
case 9:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSlideInT" fontName:@"AppleGothic" fontSize:32];
break;
case 10:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionShrinkGrow" fontName:@"AppleGothic" fontSize:32];
break;
case 11:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFlipX" fontName:@"AppleGothic" fontSize:32];
break;
case 12:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFlipY" fontName:@"AppleGothic" fontSize:32];
break;
case 13:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFlipAngular" fontName:@"AppleGothic" fontSize:32];
break;
case 14:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionZoomFlipX" fontName:@"AppleGothic" fontSize:32];
break;
case 15:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionZoomFlipY" fontName:@"AppleGothic" fontSize:32];
break;
case 16:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionZoomFlipAngular" fontName:@"AppleGothic" fontSize:32];
break;
case 17:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFade" fontName:@"AppleGothic" fontSize:32];
break;
case 18:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionCrossFade" fontName:@"AppleGothic" fontSize:32];
break;
case 19:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionTurnOffTiles" fontName:@"AppleGothic" fontSize:32];
break;
case 20:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSplitCols" fontName:@"AppleGothic" fontSize:32];
break;
case 21:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionSplitRows" fontName:@"AppleGothic" fontSize:32];
break;
case 22:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFadeTR" fontName:@"AppleGothic" fontSize:32];
break;
case 23:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFadeBL" fontName:@"AppleGothic" fontSize:32];
break;
case 24:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFadeUp" fontName:@"AppleGothic" fontSize:32];
break;
case 25:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionFadeDown" fontName:@"AppleGothic" fontSize:32];
break;
case 26:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionRadialCCW" fontName:@"AppleGothic" fontSize:32];
break;
case 27:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionRadialCW" fontName:@"AppleGothic" fontSize:32];
break;
case 28:
trasitionlabel= [CCLabelTTF labelWithString:@"CCTransitionPageTurn" fontName:@"AppleGothic" fontSize:32];
break;
}
// position the label on the center of the screen
if(trasitionlabel != nil)
{
trasitionlabel.position = ccp( size.width /2 , size.height/2 );
// add the label as a child to this Layer
[self addChild: trasitionlabel z:2 tag:2];
}
CCLabelTTF* label= [CCLabelTTF labelWithString:@"coolkim.tistory.com" fontName:@"AppleGothic" fontSize:32];
// position the label on the center of the screen
label.position = ccp( size.width /2 , size.height/4 );
// add the label as a child to this Layer
[self addChild: label z:2 tag:2];
}
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if( (self=[super init])) {
self.isTouchEnabled = YES;
[self schedule:@selector(updateText) interval:TRANSITION_DURATION];
}
return self;
}
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
// in case you have something to dealloc, do it in this method
// in this particular example nothing needs to be released.
// cocos2d will automatically release all the children (Label)
// don't forget to call "super dealloc"
[super dealloc];
}
- (void) registerWithTouchDispatcher {
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
NSLog(@"ccTouchBegan : %f , %f",convertedLocation.x ,convertedLocation.y);
return YES;
}
- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
NSLog(@"ccTouchMoved %f , %f",convertedLocation.x ,convertedLocation.y);
}
- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
NSLog(@"ccTouchEnded : %f , y : %f",convertedLocation.x ,convertedLocation.y);
//touch up
//replace scene
switch (transitionIndex)
{
case 0:
[[CCDirector sharedDirector] replaceScene:[CCTransitionRotoZoom transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 1:
[[CCDirector sharedDirector] replaceScene:[CCTransitionJumpZoom transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 2:
[[CCDirector sharedDirector] replaceScene:[CCTransitionMoveInL transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 3:
[[CCDirector sharedDirector] replaceScene:[CCTransitionMoveInR transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 4:
[[CCDirector sharedDirector] replaceScene:[CCTransitionMoveInT transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 5:
[[CCDirector sharedDirector] replaceScene:[CCTransitionMoveInB transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 6:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInL transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 7:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInR transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 8:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInB transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 9:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 10:
[[CCDirector sharedDirector] replaceScene:[CCTransitionShrinkGrow transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 11:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFlipX transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 12:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 13:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFlipAngular transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 14:
[[CCDirector sharedDirector] replaceScene:[CCTransitionZoomFlipX transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 15:
[[CCDirector sharedDirector] replaceScene:[CCTransitionZoomFlipY transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 16:
[[CCDirector sharedDirector] replaceScene:[CCTransitionZoomFlipAngular transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 17:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 18:
[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 19:
[[CCDirector sharedDirector] replaceScene:[CCTransitionTurnOffTiles transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 20:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSplitCols transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 21:
[[CCDirector sharedDirector] replaceScene:[CCTransitionSplitRows transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 22:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFadeTR transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 23:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFadeBL transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 24:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFadeUp transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 25:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFadeDown transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 26:
[[CCDirector sharedDirector] replaceScene:[CCTransitionRadialCCW transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 27:
[[CCDirector sharedDirector] replaceScene:[CCTransitionRadialCW transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
case 28:
[[CCDirector sharedDirector] replaceScene:[CCTransitionPageTurn transitionWithDuration:TRANSITION_DURATION scene:[DateSceneLayer scene]]];
break;
}
transitionIndex++;
if(transitionIndex == TRANSITION_MAX)
transitionIndex=0;
}
- (void)ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event {
}
@end
|