在特定时间内显示SKSpriteNode

时间:2015-09-25 13:52:37

标签: swift sprite-kit

在我的GameOverScene我有SKSpriteNode我希望在特定时间内出现。因此,当场景GameOverScene加载SKSpriteNode纹理“再​​次播放”时,需要2秒才能显示。

playButton = SKSpriteNode(texture: playAgainTex)
    playButton.position = CGPointMake(self.frame.size.width * 0.45, self.frame.size.height * 0.33)
    self.addChild(playButton)

1 个答案:

答案 0 :(得分:0)

请试试这个

    let playButton = SKSpriteNode(texture: playAgainTex)
    playButton.position = CGPointMake(self.frame.size.width * 0.45, self.frame.size.height * 0.33)

    let wait = SKAction.waitForDuration(2)
    let add = SKAction.runBlock { self.addChild(playButton) }
    let sequence = SKAction.sequence([wait, add])
    self.runAction(sequence)

希望这有帮助。