方法.removeFromParent()不移除sprite。怎么了?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
guard touches.first != nil else {
return
}
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
sprite!.addChild(myShot)
let myShotAction = SKAction.group([SKAction.scaleBy(0.1, duration: 0.5), myShotAnimation])
let actionRemove = SKAction.removeFromParent()
myShot.runAction (SKAction.sequence([myShotAction, actionRemove]))
}带有动画的雪碧"myShot“不会消失。
发布于 2016-05-30 03:53:22
疯人院。我代替了行动
SKAction.repeatActionForever每次行动
SKAction.repeatAction一切都成功了。
发布于 2016-05-30 08:58:03
仅仅是因为actionRemove永远不会被调用。
当你发射:
myShot.runAction (SKAction.sequence([myShotAction, actionRemove]))依次运行myShotAction SKAction,并在完成后运行actionRemove。但是,如果第一个SKAction是一个永不结束的动作(SKAction.repeatActionForever),那么actionRemove将永远不会调用。
https://stackoverflow.com/questions/37513830
复制相似问题