-1

So this has been stumping me for a while. I'd like to track multiple touches at the same time on the iPhone for a game, storing them as CGPoints and analyzing their movements in real time (probably within the touchesMoved func) to perform actions in the game.

I've read up on some solutions but I haven't been able to modify them to my exact needs. The answers in these two posts are probably on the right track:

Multi-touch gesture in Sprite Kit

Get coordinates of multiple touches in Swift

I have my ideas for some implementations but they don't seem to work, and I'd like to see some more ideas. Any help and suggestions are greatly appreciated. Gotta get through this roadblock!

Community
  • 1
  • 1
oaSysFox
  • 1
  • 1

1 Answers1

0

Try something like this:

class CustomView: UIView {
   override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
      let touchArray = touches.allObjects as [UITouch]
      println("-----")
      println("\(touchArray.count) touches:")
      for touch in touchArray{
         println(touch.locationInView(self))
      }
   }
}
Nikita Arkhipov
  • 1,208
  • 4
  • 11
  • 28