I have two SKSpriteNode
the cat and the black wall, each of them have the class physicsBody
associated so the cat is on top of the black wall.
The cat moves it with the finger with the function touchesMoved
of the following form:
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
if node == miaum {
gato.position = location
gato.physicsBody?.affectedByGravity = false
}
}
}
The problem is that as the cat follows the finger, when the finger passes from one side to the other through the black wall, the cat passes too and that should not happen. Is there a quick and easy way to program so that does not happen?
Image that shows the problem that is happening, I move the cat with my finger, according to the code explained above: