如何在SpriteKit swift函数中传递NSTimer作为参数

时间:2015-08-05 08:35:36

标签: swift sprite-kit sprite swift2

我有一个简单的函数来移动我的精灵预定义的持续时间。我希望我传入的持续时间作为持续时间在函数参数中作为NSTimer传递。我的功能如下!

func moveGooses(){
    let path = UIBezierPath()
    path.moveToPoint(CGPoint(x:self.parentScene.frame.width*0.99  , y:   self.parentScene.frame.height*0.90))
    path.addCurveToPoint(CGPoint( x:self.parentScene.frame.width*0.01  , y:   self.parentScene.frame.height*0.90), controlPoint1: CGPoint(x: self.parentScene.frame.width*0.01, y: self.parentScene.frame.height*0.90) , controlPoint2: CGPoint(x: self.parentScene.frame.width*0.01  , y:   self.parentScene.frame.height*0.90))
    let anim            = SKAction.followPath(path.CGPath, asOffset: false, orientToPath: false, duration: 3.0)
    let seq             = SKAction.sequence([anim])
    let removeAction    = SKAction.runBlock{
        let myGameScene =   self.parentScene as GameScene
        self.removeFromParent()
    }
    self.runAction(SKAction.sequence([seq,removeAction]))
}

1 个答案:

答案 0 :(得分:1)

你的问题很模糊,但我相信这是你根据问题标题所做的事情:

func timerAsParam(timer: NSTimer) {
    //timer is a local nstimer
}