Bram Roelandts
Bram Roelandts

Reputation: 470

Removing All Children

I'm having a little problem while developing a small iOS game. In touchesbegan, I add the arc4random called div to the screen, but in this method:

class TouchableSpriteNode : SKSpriteNode
{
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

        print("Touch")

        self.removeAllChildren()


    }

I want to remove the image from the screen again. This class get's called when the node itself is tapped. Any help is appreciated! Thanks!

Upvotes: 1

Views: 111

Answers (1)

Charles A.
Charles A.

Reputation: 11123

You can either move those touch handling methods into the parent and remove the specific child that is touched, or you can try:

self.removeFromParent()

Incidentally if SKSpriteNode is anything like UIView - you'll want to implement all four touch handling methods even if you don't need them all.

Upvotes: 2

Related Questions