Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
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.