I am trying to add SKEmitterNode
to the ball SKSpriteNode
as a child.But also at the same time, I am rotating
my ball node. But the problem is, the rotation of the ball node causes the emitter node to rotate (as the emitter node is child to ball node). Is there anything I could do to not rotate the emitter node,but rotate the ball node?
I added the ball node as:
SKSpriteNode * ball = [SKSpriteNode spriteNodeWithImageNamed:imageName];
ball.name=name;
ball.size=size;
ball.anchorPoint=CGPointMake(0, 0);
[self addChild:ball];
and I added the emitter node as:
SKEmitterNode *burstEmitter =
[NSKeyedUnarchiver unarchiveObjectWithFile:_emitterNodePath];
[ball addChild:burstEmitter];
and when ball hits the wall, I am rotating the ball:
-(void)didBeginContact:(SKPhysicsContact *)contact
{
SKSpriteNode * firstNode = (SKSpriteNode*)contact.bodyA.node;
SKSpriteNode * secondNode = (SKSpriteNode *)contact.bodyB.node;
if (firstNode.physicsBody .categoryBitMask == wallHitCategory || secondNode.physicsBody.categoryBitMask == wallHitCategory) {
NSLog(@"first sound and then rotate ball");
[self runAction:[SKAction playSoundFileNamed:@"basketBall bounce.WAV" waitForCompletion:NO]];
secondNode.anchorPoint=CGPointMake(0.5, 0.5);
[secondNode runAction:[SKAction rotateByAngle:degToRad(180.0f) duration:3.0]];
}
}
Is it possible to rotate the parent node but not its child node?