Reputation: 6826
I want to show an effect node if a node is selected. If not, I want to turn off/remove that effect. (I set a node as selected in touchesBegan
.)
I use the code below. Turning on and off the effect node is mixing my mind up because I add the main node into an effect node. How should I turn it off without loosing the main node too? I can change the color of the effect to transparent to hide it but it doesn't sound like the right way... Moving main node from effect node to parent of effect node may work but I have to reposition it again so it doesn't sound like the right way too..
What is one of the correct ways of doing this? (correct = good for performance while not increasing coding complexity)
SKShapeNode* tile = [SKShapeNode node];
[tile setPath:CGPathCreateWithRoundedRect(CGRectMake(0, 0, 60, 100), 4, 4, nil)];
tile.strokeColor = tile.fillColor = [UIColor colorWithRed:0.0/255.0
green:128.0/255.0
blue:255.0/255.0
alpha:1.0];
tile.position = CGPointMake(10, 100);
SKEffectNode *effectNode = [[SKEffectNode alloc] init];
GlowFilter *glowFilter = [[GlowFilter alloc] init];
[glowFilter setGlowColor:[[UIColor yellowColor] colorWithAlphaComponent:1]];
[effectNode setShouldRasterize:YES];
[effectNode setFilter:glowFilter];
effectNode.position=CGPointMake(0, 0);
[effectNode addChild:tile];
[self addChild:effectNode];
Upvotes: 2
Views: 464