0

i want to animate images randomly in grid so i have taken Timer.

This is my code :

 id wait = [SKAction waitForDuration:self.initialTimerValue / 1000];

id run = [SKAction runBlock:^{
    //My Custom Method
}];
[self runAction:[SKAction repeatActionForever:[SKAction sequence:@[wait, run]]]];

i want to disable timer on Touch Event,how to invalidate timer ? Can you please Help ?

  • You can use the method `invalidate`, described here: [Apple Developer Documentation](https://developer.apple.com/documentation/foundation/timer/1415405-invalidate) – Fabio Berger Sep 26 '17 at 08:46
  • @FabioBerger i am not using NSTimer.so how to invalidate it? –  Sep 26 '17 at 08:50
  • What are you using instead of NSTimer? Please describe such important things in your post, otherwise it will he hard to give you a good answer. – Fabio Berger Sep 26 '17 at 09:02
  • @FabioBerger i am using SKAction which i describe in question.that is code to run timer. or any other way to run timer in scenekit? –  Sep 26 '17 at 09:18
  • Ok if I understand correct, you want to stop the action that repeats forever? – Fabio Berger Sep 26 '17 at 09:24
  • @FabioBerger yes stop and pause –  Sep 26 '17 at 10:02
  • Check this.. https://stackoverflow.com/questions/35502326/stopping-an-running-skaction-sprite-kit – Fabio Berger Sep 26 '17 at 10:03
  • @FabioBerger worked for me.thanks a lot –  Sep 26 '17 at 10:35
  • Possible duplicate of [Stopping an running SKAction - Sprite Kit](https://stackoverflow.com/questions/35502326/stopping-an-running-skaction-sprite-kit) – Knight0fDragon Sep 26 '17 at 12:42
  • @FabioBerger how to pause action using SKAction –  Oct 12 '17 at 13:20

0 Answers0