Is there anyway I can animate a child node independent of it's parent?
For example
//create parent node
SKNode* parent = [SKSpriteNode spriteNodeWithColor:[UIColor whiteColor] size:CGSizeMake(100,100)];
[myScene addChild:parent];
//create child node (add to parent)
SKNode* child = [SKSpriteNode spriteNodeWithColor:[UIColor whiteColor] size:CGSizeMake(50,50)];
child.position = CGPointMake(0,0);
[parent addChild:child];
//attempt to run action on child
[child runAction:[SKAction moveByX:25 y:25 duration:1.0f]];
Nothing happens. However, if I run the same action on the parent, it works as expected.
How can I run an action on a child nodes independent of the parent? This must be possible (e.g. wings flapping on a bird, tires turning on a car, landing gear deploy on an airplane, etc.).
If this is a limitation of sprite kit, can you recommend another game engine framework that does not have these limitations?
The ONLY way I am able to reposition a node is if it is directly added to a scene. Child nodes cannot be repositioned. This is a huge limitation in this framework. Very disappointing for sure.
UPDATE:
I discovered that if I remove the physics body (child.physicsBody = nil) I can change the position (child.position = newPosition) but I cannot run an action that changes the position ([child runAction: [SKAction moveByX:25 y:25 duration:1.0f]).
Thanks!!
SKNode
andSKSpriteNode
and 2) missing ]'s in yourUIColor
method calls. SpriteKit fully supports running actions on children nodes. Your parent node is a child of the scene. – 0x141E