1

Im using this code to add background music to my game levels

[self runAction:[SKAction playSoundFileNamed:@"dasdas.mp3" waitForCompletion:NO]];

I want it to stop when Game Over happens. Is there a way to cancel/stop the SKAction, lower volume, anything to stop it?

Thanks

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • it's about sound files and skaction. this thread has the answer : http://stackoverflow.com/a/22590464/1242291 – arun.m Jun 23 '14 at 19:59

2 Answers2

0

Instead of:

[node runAction:action]

use:

[node runAction:action withKey:@"BackgroundMusicAction"]

Then stop it by calling the SKNode's method:

- (void)removeActionForKey:(NSString *)key;

with a key you used for creating the action.

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
  • Im still confused, Im a NOOB. What do I write for node, and NSSTRig and key, can you explain me, it will be a great deal – user3653566 May 27 '14 at 21:13
0

instead of [node runAction withKey:@"BackgroundMusicAction"];

You would want to use [self runAction withKey:@"BackgroundMusicAction"];

rmaddy's code is right, its just in a generic form.