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
self.view?.multipleTouchEnabled=true
// 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.
ifNode==mySprite
{
mySprite.removeFromParent()
// indicate the location of
print(tNode)
}
}
}
}
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.
542 Unable to install versioned in Google Colab
546 Understanding How to Configure Google API Key
725 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
549 PHP ssh2_scp_send fails to send files as intended
539 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.