Welcome to the Treehouse Community
Looking to learn something new?
Delay Touch On Game Over Screen
I am trying to add a delay to the touch one you lose all your lives and the game is over.
Right now when you lose you automatically restart because you might be moving your finger too fast.
I tried adding the following line of code to the touchesBegan method:
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(presentScene:) userInfo:nil repeats:NO];
Any better options?
Also does anyone know how to save high scores in the game? Thank you.
There are a few things you can do here. Since your code is in the touches began method, every time to touch the screen it uses that code. You can write a small bool function call wait time and have it return true after a time delay, then in your touches began method your would wrap an if with that clause.
it is a tad over board but it will be helpful if you want to do other things in that delay function and make sure you save that delay value as a constant.
For your other question that is sort of up to how you want to do it. you can do it in App Center if you want to integrate your app with it, or you can save it in the plist if you want to keep it local. If you want to get more complicated, you can store in a db either locally or using a back-end like parse.
Come back and let us know how you are doing it. I am interested to see your direction.