All i\'m trying to do is be able to drag and drop a sprite across the screen. I\'ve tried the following code:
override func touchesBegan(touches: Set
I have an implementation where I've subclassed a UIImageView and called it a "DraggableImage"
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
originalPosition = self.center
}
override func touchesMoved(_ touches: Set, with event: UIEvent?) {
if let touch = touches.first {
let position = touch.location(in: self.superview)
self.center = CGPoint(x: position.x, y: position.y)
}
}
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
self.center = originalPosition
}