Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide and unhide SKSprite Node

I am trying to hide a node when it's clicked and unhide it when a button is clicked. After unhiding the node, I can't click it again but I want it to be clickable again. Below is my code for hiding and unhiding using SKAction. Am I missing something?

when the ball Node is clicked it is hidden and added to an array clickedBall

ballNode.runAction(SKAction.hide())
clickedBall.append(ballNode)

when the button is clicked, it is shown via array clickedBall

clickedBall.last?.runAction(SKAction.unhide())

but I can't click the node again to hide it again..

please help.. thank you

like image 622
tryinghardladyprogrammer Avatar asked Mar 03 '26 13:03

tryinghardladyprogrammer


1 Answers

When the node is clicked, instead of running an action, you can use the node's isHidden property:

ballNode.isHidden = true

and then set the value to false when you want the node to reappear

like image 54
Jonathan H. Avatar answered Mar 05 '26 02:03

Jonathan H.