I have created an SKAction group that alters the SKSpriteNode image (alpha and rotation) whilst playing a sound effect. However, when I runAction: the sound effect is played, but the image remains fixed.
In my subclassed SKSpriteNode (The Sheep) I have the following code that adds another SKSpriteNode (The Food) as a child:
-(void)setupEatingAction
{
_grassEating = [SKSpriteNode spriteNodeWithImageNamed:@"SheepFood"];
_grassEating.size = self.size;
_grassEating.anchorPoint = CGPointMake(0.5, 0.5);
_grassEating.alpha = 0.5;
_grassEating.zPosition = -1;
SKAction *fadeIn = [SKAction fadeInWithDuration:0.01];
SKAction *soundFX = [SKAction playSoundFileNamed:@"Munching2s.mp3" waitForCompletion:NO];
SKAction *rotate = [SKAction sequence:@[[SKAction rotateToAngle:degsToRads(-20.0) duration:kMovementAnimationInterval/4.0],[SKAction rotateToAngle:degsToRads(0.0) duration:kMovementAnimationInterval/4.0]]];
SKAction *eatAction = [SKAction group:@[fadeIn,soundFX,rotate]];
_grassEating.userData = [NSMutableDictionary dictionaryWithObject:eatAction forKey:KEY_EatAction];
[self addChild:_grassEating];
}
Then when I want the action group to run, I do the following:
-(void)eat
{
if(![_grassEating actionForKey:KEY_EatAction])
{
[_grassEating runAction:[_grassEating.userData objectForKey:KEY_EatAction] withKey:KEY_EatAction];
}
}
_grassEating is a property of my parent node:
@property (nonatomic,retain) SKSpriteNode *grassEating;
As I said, I can hear the sound effect playing, but the image isn't changed?!? For the life of me I can't work out why, and I've spent a lot of time trying to work out what is going on... any ideas?
I should also point out (although I don't think is anything to do with it) that this problem appears in both simulator and on hardware - both running iOS7.
I don't know if this is related iOS Spritekit Cannot Run SKAction on a Subclassed SKSpriteNode
But, it's the closest I can find and doesn't appear to be the same problem (on the surface).