I have a problem using the Sprite Kit and when I want to play sound after user interaction.
The user listens to music using an application (such as Spotify).
A user wants to play my game while he is listening to his song. Currently, when an application launches my application, its song stops.
I would like to prevent this behavior: in fact: how to not play sound if another application uses “sound” or how can I play sound? And continue playing the user's music.
This is currently my code:
@property (strong, nonatomic) SKAction *hitSound;
In the init method:
_hitSound = [SKAction playSoundFileNamed:@"laugh.caf" waitForCompletion:NO];
After clicking on the user screen:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
SKAction *sequence = [SKAction sequence:@[_hitSound]];
[node runAction:sequence completion:^{
}];
}