我有一个角色拍摄,我希望他只在用户触摸屏幕时拍摄,我不断收到此错误“'GameScene'没有名为'stimer'的成员 这里是代码如何停止NSTimer
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
var stimer = NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: Selector("spawnShot"), userInfo: nil, repeats: true)
let location = touch.locationInNode(self)
player.position.x = location.x
}
}
override func touchesEnded(touches: Set<NSObject>, withEvent: UIEvent){
for touch: AnyObject in touches{
if self.stimer.valid{
self.timer.invalidate()
self.timer = nil
}
}
}