ios - Separate codes for separate touches -
i have sknode, , when touch it, under touches began, runs code:
if node.name == "0.5" { node.name = "test" node.fillcolor = uicolor(hue: 1.0, saturation: 1.0, brightness: 1.0, alpha: 1.0) print(node.name) } else if node.name == "test" { node.name = "0.5" node.fillcolor = uicolor(hue: 0.4, saturation: 1.0, brightness: 1.0, alpha: 1.0) }
the above code should change node blue red , blue each touch on it. came saying "optional "test"" registering name change , color change, when click on again, doesn't change color again? why?
thanks
the following code should want :
if node.name == "0.5" { node.name = "test" node.fillcolor = uicolor(hue: 1.0, saturation: 1.0, brightness: 1.0, alpha: } else if node.name == "test" { node.name = "0.5" node.fillcolor = uicolor(hue: 0.5, saturation: 1.0, brightness: 1.0, alpha: 1.0) }
using switch case might idea if start having more 2 possible node names.
Comments
Post a Comment