I have two nodes in my scene. One is ball and one is background. Both are added to the scene as childs.
When the ball gets hit to the wall, I am trying to rotate the ball.
if (!firstNode.physicsBody.resting) {
//first node gets the reference of ball node
[firstNode runAction:[SKAction rotateToAngle:degToRad(5.0f) duration:1.0]];
}
The the debugger throws the error:
SKScene: Animating the rotation of a SKScene has no effect.
I am not trying to rotate SKScene
. I am trying to rotate a SKSpriteNode
, but why do I get the error?
Surprisingly, I do the same thing for my other node, and it didnt gave any error.
SKAction *rotateAction = [SKAction rotateByAngle:degToRad(180.0f) duration:2.0];
[_ringNode runAction:[SKAction repeatActionForever:rotateAction]];
Then why do the error occur in my first case?
I am using the didBeginContact
to detect collision between nodes:
and in this method:
-(void)didBeginContact:(SKPhysicsContact *)contact
{
SKSpriteNode * firstNode = (SKSpriteNode*)contact.bodyA.node;
SKSpriteNode * secondNode = (SKSpriteNode *)contact.bodyB.node;
}
Here the first node is returned as SKScene
though I tried to convert it to SKSpriteNode
. Somehow the wall is considered as SKScene
. So I am unable to animate the first node as it is SKScene
.
I can animate the secondNode
which is a SKSpriteNOde
.