I was trying to make a nice compact switch statement for use inside touchesBegan in a SpriteKit based game.
something like this:-
let location = touch.location(in: self)
switch location {
case button1.position : gamePlayScene()
case button2.position : settingsScene()
case button3.position : highScoreScene()
default : break
}
but it doesn't work 😟
trying to achieve the same as:
if self.atPoint(location) == button1 {
gamePlayScene()
}
if self.atPoint(location) == button2 {
settingsScene()
}
if self.atPoint(location) == button3 {
highScoreScene()
}
is my syntax totally wrong or is it just not possible?
thanks!