touch event in spritekit

Asked 5 months ago, Updated 5 months ago, 17 views

I'd like to make a simple game and erase the node (enemy) with a touch event, but I don't know how to do it.Thank you for your cooperation.

override functouchesBegan(touches:Set<UITouch>, withEvent:UIEvent?){

    // Enable Multi-Touch

    // We're going to take out one piece of information.
    for touch intouches {
        // We're going to take a position on the scene.
        let location = touch.locationInNode(self)
        // look at the node in the position
        let touchNodes=self.nodesAtPoint(location)
        // examine each node
        US>fortNode into touchNodes{
            // If the node you touch is an enemy, erase it.

                // indicate the location of


2022-09-30 13:56

1 Answers

Only removeFromParent() disappears the node.
If the code you provided doesn't go away, I think there is a problem where there is no presentation.

*In order to eliminate duplicate questions, you may want to delete the other question as well as leave the other question.

2022-09-30 13:56

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.