0

What would be the most straightforward method to invalidate every active NSTimer in an SKScene, if multiple NSTimers are firing from multiple different functions inside the SKScene?

For example, every SKAction in an SKScene can be cancelled with the removeAllActions function. Could the NSTimer invalidation be implemented similarly?

An example of a timer setup that my SKScene has, written in swift:

NSTimer.scheduledTimerWithTimeInterval(kWalkSpeed, target: self, selector: Selector("animatePlayerNode"), userInfo: nil, repeats: true)
danh
  • 62,181
  • 10
  • 95
  • 136
klaevv
  • 457
  • 1
  • 7
  • 17

1 Answers1

2

A general method would be to store all created timers in an array, and then loop over them to invalidate.

Steve Rosenberg
  • 19,348
  • 7
  • 46
  • 53