Touch

Touch can be detected by the application at the beginning, during (move) ad the end using different provided functions. This can be very useful in SpriteKit games.

One example might be to detect a node by its assigned name

override func touchesBegan(_ touches: Set, with event: UIEvent?)
{
	for touch in touches
	{
		let location = touch.location(in: self)
		
		if atPoint(location).name == "Play"
		{
			// do stuff for node with the name "Play"
		}
	}
}

The function, atPoint, returns a SKNode or property of a node, e.g. name. More information at Help: Instance Method: atPoint(_ p: CGPoint)


Index


Comments, Corrections, Suggestions: David Bourne (david@boomer.org)
My iOS and tvOS Apps and iBooks