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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -