2015年

3月

22日

SpriteKit 画面遷移の作成

SpriteKit 画面遷移の作成

#import "CMMyScene.h"
#import "CMNextScene.h"
 
@implementation CMMyScene
 
-(id)initWithSize:(CGSize)size {   
    if (self = [super initWithSize:size]) {
        self.backgroundColor = [SKColor blueColor];
        SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial Bold"];
        myLabel.text = @"A";
        myLabel.verticalAlignmentMode = SKLabelVerticalAlignmentModeCenter;
        myLabel.fontSize = 300;
        myLabel.position = CGPointMake(CGRectGetMidX(self.frame),
                                       CGRectGetMidY(self.frame));
        [self addChild:myLabel];
    }
    return self;
}


// タッチ画面遷移
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    CMNextScene *scene = [[CMNextScene alloc] initWithSize:self.size];
     

    SKTransition *transition = [SKTransition crossFadeWithDuration:2];
    //SKTransition *transition = [SKTransition fadeWithDuration:2];
    //SKTransition *transition = [SKTransition doorsOpenHorizontalWithDuration:2];
    //SKTransition *transition = [SKTransition doorsCloseHorizontalWithDuration:2];
    //SKTransition *transition = [SKTransition doorwayWithDuration:2];
    //SKTransition *transition = [SKTransition flipHorizontalWithDuration:2];
    //SKTransition *transition = [SKTransition moveInWithDirection:SKTransitionDirectionUp duration:2];
    //SKTransition *transition = [SKTransition revealWithDirection:SKTransitionDirectionUp duration:2];
    //SKTransition *transition = [SKTransition pushWithDirection:SKTransitionDirectionLeft duration:2];
     
    [self.view presentScene:scene transition:transition];
}
 
@end

  

目 次