Been banging my head against this for a day now, and I really have no idea what's going on.
I have a very simple setup: an SKNode (let's call it base) which contains another SKNode (sub-base), as well as several SKShapeNode objects. At some time, I move one of the SKShapeNode objects (using removeFromParent) from the base node to the sub-base node. Then I apply an SKAction, which moves the node to some arbitrary position.
Except, that SKAction does not work when the SKShapeNode has been removed and added to the sub-base object. If I remove it from the sub-base, and put it back in the base, SKActions once again work.
I am completely stumped. Is there some property that gets set on a node when it's added to another node, which isn't getting properly reset when I remove it...? I can't imagine this is something that should be happening.
Any ideas would be so very welcome.
Update:
Here's some code that I can produce it with. This function is inside a subclass of SKNode. The class adds a bunch of SKShapeNodes, and it also has this other SKNode called testNode, so, without further ado:
-(void) removeThenAdd
{
[someNode removeFromParent];
[self.testNode addChild:someNode];
SKAction* action = [SKAction moveTo:CGPointMake(200, 200) duration:1];
SKNode* thatSameNodeJustAdded = [self.testNode.children objectAtIndex:0];
[thatSameNodeJustAdded runAction:action];
}
Another update!
I just found that, if I add an SKAction to the node whilst it is sitting inside the testNode, then after that remove it from the testNode and add it back to its original parent, the action is then activated. Like, what am I missing here? This must be some kind of designed behaviour I'm just not using right..