Note that there are some explanatory texts on larger screens.

plurals
  1. POSpriteKit SKAction doesn't work after removing and readding a node
    primarykey
    data
    text
    <p>Been banging my head against this for a day now, and I really have no idea what's going on.</p> <p>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.</p> <p>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. </p> <p>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. </p> <p>Any ideas would be so very welcome.</p> <p>Update:</p> <p>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:</p> <pre><code>-(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]; } </code></pre> <p>Another update!</p> <p>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..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload