Time for action – handling touches
Let's add the code that will allow us to handle touches:
Note
In this and the subsequent chapters, we're going to build on top of the Cocohunt project we started in the previous chapter. If you've completed the code of the previous chapter, simply continue from the point where you left.
If you skipped some part of the book or don't have the code for some reason, you can take the final project of the previous chapter from the book supporting files. For this chapter, you can take the code from the Chapter_04/Cocohunt_04_Final
folder.
You can download the book's supporting files at http://www.packtpub.com/support and follow the instructions.
Perform the following steps:
- Open the Xcode project at the point where we left it at the end of the previous chapter. After opening the project, open the
GameScene.m
file and add the following methods below theupdate:
method:-(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event { ...