sprite kit - Swift: skaction not executed after contact between nodes is made? -


alright, have contact detection set between 2 nodes - savior , chicken1. set here:

//this within gamescene class var screentouches = bool()      enum collidertype:uint32 {         case savior = 1         case chicken1 = 2     }          savior.physicsbody?.categorybitmask = collidertype.savior.toraw()         savior.physicsbody?.contacttestbitmask = collidertype.chicken1.toraw()         savior.physicsbody?.collisionbitmask = collidertype.chicken1.toraw()      chicken1.physicsbody?.categorybitmask = collidertype.chicken1.toraw()     chicken1.physicsbody?.contacttestbitmask = collidertype.savior.toraw()     chicken1.physicsbody?.collisionbitmask = collidertype.savior.toraw()  //this outside of gamescene class    //collision detection       func didbegincontact(contact: skphysicscontact) {          if (contact.bodya.categorybitmask == collidertype.savior.toraw() && contact.bodyb.categorybitmask == collidertype.chicken1.toraw() )  {              chicken1.hidden = true              let chickengrabbedleft = skaction.moveto(cgpointmake(self.size.width * 0.1,self.size.height * 1.2), duration:0)             chicken1.runaction(chickengrabbedleft)             println("contact made")          } else if (contact.bodya.categorybitmask == collidertype.chicken1.toraw() && contact.bodyb.categorybitmask == collidertype.savior.toraw())  {              chicken1.hidden = true             let chickengrabbedleft = skaction.moveto(cgpointmake(self.size.width * 0.1,self.size.height * 1.2), duration:0)             chicken1.runaction(chickengrabbedleft)             println("contact made")         }       } 

when savior comes in contact chicken1, need chicken1 has disappeared. is, have chicken1 becomes hidden when touches savior, isn't enough because savior still collides , user can tell object still there if isn't visible.

i don't want delete chicken1 because still need present within game. trying chicken1 move starting position (which offscreen) when touches savior. did placing skaction in above function.

it not working. when savior touches chicken1, chicken1 still gets hidden. doesn't move. should do?

from question, assume function still runs when chicken1 becomes hidden.

what can use bool changes true when savior comes contact chicken1 , use condition before running action , change false when want no longer interact objects.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -