シーンの切り替え時に、アニメーションをさせるかどうかを制御できます。
SKTransitionクラスの
プロパティ | 説明 |
---|---|
pausesOutgoingScene | YESなら、今のシーンのアニメーションを停止させる |
pausesIncomingScene | YESなら、次のシーンのアニメーションを停止させる |
このようにシーンを切り替えると、pulseアクションはアニメーションありになり、次のシーンのアニメーションはなし(デフォルトYES)になります。
HelloScene.m
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
SKSpriteNode *spaceship = (SKSpriteNode *)[self childNodeWithName:@"spaceship"];
if (spaceship != nil) {
SKAction *action = [spaceship actionForKey:@"pulse"];
if (action != nil) {
[spaceship removeActionForKey:@"pulse"];
}
else {
SKAction *fadeOut = [SKAction fadeOutWithDuration:1.0];
SKAction *fadeIn = [SKAction fadeInWithDuration:1.0];
SKAction *pulse = [SKAction sequence:@[fadeOut, fadeIn]];
SKAction *pulseForever = [SKAction repeatActionForever:pulse];
[spaceship runAction:pulseForever withKey:@"pulse"];
SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:10.0];
reveal.pausesOutgoingScene = NO;
SKScene *spaceshipScene = [[SpaceshipScene alloc] initWithSize:self.size];
[self.view presentScene:spaceshipScene transition:reveal];
}
}
}
今回はここまで。