I have several levels all using the same sound effects. Instead of having the same code in every level, I consolidated all of the sounds into a singleton class. However, having it in a singleton no sound is played when I run the method from other classes. I have no errors or warnings.
When I have the same code in each class I have no problems playing the sound.
Question: Does SKAction playSoundFileNamed not work when called from a singleton or is my code missing something?
My singleton header file...
-(void)soundSwordWhoosh;
My singleton methods file...
@implementation Animations{
SKAction *swordWhooshSound;
}
-(id)init {
self = [super init];
if (self)
{
swordWhooshSound = [SKAction playSoundFileNamed:@"SwordWhoosh.mp3" waitForCompletion:YES];
}
return self;
}
-(void)soundSwordWhoosh {
[self runAction:swordWhooshSound];
}
I then call the method like this:
[_animations soundSwordWhoosh];