xcode - How would I add a "+1" animation when my node comes in contact with a coin? -


i got node collect coins want type of animation when happens. how add "+1" animation every time node collects coin? dont know if should use skaction , have run action every time contact occurs between node , coins.

yes did skaction (when put code in "update" method show everytime earn coin):

if cgrectintersectsrect(player.frame, coin.frame) {         coins++ //your variable          let addcoinslabel = sklabelnode(fontnamed: "chalkboardse-regular")         addcoinslabel.text = "+1"         addcoinslabel.fontsize = 40         addcoinslabel.fontcolor = uicolor.redcolor()         addcoinslabel.zposition = 200         addcoinslabel.position = cgpoint(x: cgrectgetmidx(self.frame), y: self.frame.size.height*0.7)         self.addchild(addcoinslabel)          let actionlabelfadein = skaction.fadeinwithduration(0.5)         let actionlabelmove = skaction.moveby(cgvector(dx: 0.0, dy: 100), duration: 0.5)         let actionremovefromparent = skaction.removefromparent()          let sequence = skaction.sequence([actionlabelfadein, actionlabelmove, actionlabelfadeout, actionremovefromparent])          addcoinslabel.runaction(sequence)     } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -