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

How to pass the NSTimer as parameter in function in SpriteKit swift

我有一个简单的功能可以在预定义的持续时间内移动我的精灵。我希望我传入的持续时间作为持续时间作为 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]))
}

您的问题含糊不清,但根据问题标题,我相信这就是您要尝试做的事情:

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