I know that a similar question was asked before this question, but here is my problem. I use the following simple code for touch and SKNode.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touch = touches.first as UITouch!
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
Then I delete the node strokes as follows:
node.removeFromParent()
Now my problem is that the node image I touch is small. Therefore, it is very difficult to accurately capture the touch. I do not want the image to be larger. This is not a problem, but the nature of my game is such that I:
1) It is not possible to use another invisible SKSpriteNode on top of my SKSpriteNode image to increase the registered touch area, because each image has a unique name, so I need a specific node to be affected and deleted.
2) I canβt give the invisible SKSpriteNode the same name as the SKSpriteNode image, because only the invisible SKSpriteNode will be deleted when touched.
3) I tried to load the new SKSpriteNode into the original SKSpriteNode image in order to increase the tangible area, but once again, when touched, only the invisible SKSpriteNode is deleted, and not the SKSpriteNode image that I want.
So how can I increase the tangible area? Is there any way:
1) Remove all nodes associated with the node that have been affected? Then it will work if I add an invisible SKSpriteNode inside the original node to increase the visibility. If they have the same name. But I already tried "node.removeAllChildren ()" ... didn't work.
2) - , TouchesBegan? .
? :)
------------------------------- UPDATE --------------- ------------
! SKNode, , SKNodes. - SKNode SKNode. ?
let original = SKSpriteNode(imageNamed: "original")
original.size = CGSize(width: 50, height: 50)
original.zPosition = 0
let invisible = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(70, 70))
invisible.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))
invisible.alpha = 1.0
invisible.zPosition = 1
invisible.name = original.name
invisible.addChild(original)
self.addChild(invisible)