ios - The sprite kit nodes can't actually be removed from parent -


i have made 30 bullets mutablearray reuse them.

for var = 0; < 30; i++ {     var bullettmp = sharedatlas.getinstance().getspritenode(skspritetype.bullet)      bullettmp.physicsbody = skphysicsbody(rectangleofsize: bullettmp.size)     bullettmp.physicsbody.dynamic = true     bullettmp.physicsbody.categorybitmask = bulletcategory     bullettmp.physicsbody.contacttestbitmask = enemycategory     bullettmp.physicsbody.collisionbitmask = enemycategory      movebullettotop = skaction.movetoy(self.frame.height, duration: nstimeinterval((self.frame.height - plane.position.y) / 400.0))      bulletgroup.addobject(bullettmp) } 

the bullets parent sknode

bullets.runaction(skaction.sequence([skaction.waitforduration(1.5), (skaction.repeatactionforever(skaction.sequence([skaction.waitforduration(0.05),skaction.runblock({     var newbullet:mgspritenode!      if self.bulletindex < 29{         self.bulletindex++     }else{         self.bulletindex = 0     }     newbullet = self.bulletgroup.objectatindex(self.bulletindex) mgspritenode      newbullet.removeallactions()     newbullet.removefromparent()     print(self.childnodewithname("bullets").children.count)//max value keeps 30      newbullet.runaction(self.movebullettotop)      newbullet.position = self.plane.position     newbullet.position.y += self.plane.size.height * 0.5      self.childnodewithname("bullets").addchild(newbullet)  })])))])) 

the question is: have remove parent after bullet moves while. nodes number on screen keep increasing. children of bullets 30 . if move of bullets, ok. nodes? had been removed?


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -