swift - Does Sprite Kit SKAction with time duration Slow Function Execution? -


i have function in sprite kit game game character dies , has death animation. in same method set attributes let update function know game on score can stop being incremented , other things. when runs, deathanimation function seems slow down execution of other variables being set. score keeps being incremented when should stop example. why this? update function or animation time duration slow entire method being executed right away? in advance!

here deathanimation method

func deathanimation() {     //set shield death     self.yourdead = true     self.shield.position = cgpointmake(self.frame.maxx * 2, self.frame.maxy + self.ape.size.height * 10)     self.shield.hidden = true     self.shieldactivated = false     //set ape image default     self.ape.runaction(skaction.settexture(sktexture(imagenamed: "ape"), resize: true))     self.ape.zrotation = 0     //changes physicsbody values doesn't collide     self.ape.physicsbody?.dynamic = false     self.ape.physicsbody?.categorybitmask = collidertype.asteroid.rawvalue     self.ape.physicsbody?.contacttestbitmask = collidertype.ape.rawvalue     self.ape.physicsbody?.collisionbitmask = collidertype.ape.rawvalue     self.ape.zposition = 10     //bring ape front     let death = skaction.sequence([                         skaction.group([                                 skaction.scaleby(4, duration: 0.5),                                 skaction.moveto(cgpointmake(self.frame.minx + ape.size.width * 2, self.frame.miny - ape.size.width * 2), duration: 2),                                 skaction.repeataction(skaction.rotatebyangle(cgfloat(m_pi_4), duration: 0.2), count: 8)                             ]),                         skaction.runblock({self.movetogameoverview();})                     ])     ape.runaction(death)        //run animation sequence } 

here code check if player dead or not , within update function. didn't include of update function because more care at.

//take asteroids off screen , increment score     enumeratechildnodeswithname("asteroid", usingblock: {(node: sknode!, stop: unsafemutablepointer <objcbool>) -> void in         //move asteroids off screen         node.position = cgpointmake(node.position.x, node.position.y + self.gravity)         //if out of screen         if node.position.y > self.frame.size.height + self.largeasteroid.size.width {             node.removefromparent()             if !self.yourdead {         //if not dead                 self.score++                 self.scoretext.text = string(self.score)                 //increase asteroid speed                 if self.score > 20 * self.tenscounter {                     self.gravity++                     self.tenscounter++                 }             }         }     }) 

the code provided looks fine. try checking few things.

  1. make sure not calling deathanimation() on , on again.

  2. make sure not doing enumeratechildnodeswithname before deathanimation().

  3. make sure aren't incrementing score somewhere else.

those reasons can think score continue go after set self.yourdead = true helps.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -