Home SKAction.sequence within and SKAction.sequence doesn't run
Reply: 0

SKAction.sequence within and SKAction.sequence doesn't run

Marin
1#
Marin Published in 2017-12-07 22:35:08Z

I am having a bit of a problem with this code. Inside didMove I am calling SKAction.sequence which runs fine, and creates the monsters.

However I want to be able to delete these monsters and am not being able to after a period of time.

I am calling addMonster() function and within it I have an SKaction.sequence call to fade out and remove the monsters. It doesn't seem to run though....

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]))
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.397642 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO