LoginSignup
1
1

More than 5 years have passed since last update.

SpriteKit入門 -19-

Posted at

シーンの切り替え時に、アニメーションをさせるかどうかを制御できます。

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];
        }
    }
}

今回はここまで。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1