SashDing SashDing - 1 year ago 96
iOS Question

SKAction.removeFromParent do not remove a sprite with SKAction.repeatActionForever

method .removeFromParent() does not remove the sprite. What's wrong?

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
guard touches.first != nil else {

let myShot = SKSpriteNode()
let myShotAnimation = SKAction.repeatActionForever(SKAction.animateWithTextures(myShotTexture, timePerFrame: 0.01))
myShot.size = CGSizeMake(200, 200)
myShot.anchorPoint = CGPoint(x: 0.5, y: 0.5)
myShot.zPosition = 0
let myShotAction =[SKAction.scaleBy(0.1, duration: 0.5), myShotAnimation])
let actionRemove = SKAction.removeFromParent()
myShot.runAction (SKAction.sequence([myShotAction, actionRemove]))


sprite "myShot" with animation does not disappear

Answer Source

Madhouse. I replaced the action


per action


and everything worked.