我对此代码有点问题。在didMove里面,我正在调用运行良好的SKAction.sequence,并创建了怪物。
但是我希望能够删除这些怪物,并且在一段时间后无法恢复。
我正在调用addMonster()函数,在其中我有一个SKaction.sequence调用淡出并删除怪物。它似乎无法运行......
override func didMove(to view: SKView) {
run(SKAction.repeatForever(
SKAction.sequence([
SKAction.run(addMonster),
SKAction.wait(forDuration: 5.0)
//SKAction.run(addMonster),
])
))
}
func addMonster() {
let monster = Enemy(enemySpriteName: "triangle", name: enemyName,
position: CGPoint(x: background.position.x + 300 + CGFloat(enemycount),
y: background.position.y + 50 + CGFloat(enemycount)), zPosition: 9)
self.addChild(monster)
//This part doesn't seem to run ?!
let scale = SKAction.scale(to: 0.1, duration: 2.5)
let fade = SKAction.fadeOut(withDuration: 3.5)
let actionMoveDone = SKAction.removeFromParent()
monster.run(SKAction.sequence([scale, fade, actionMoveDone]))
}