Book

Tap Move ShakeTap, Move, Shake
A Hands-on Guide to Creating Multi-touch Games with iPad and iPhone

“This book is so great.” –Steve Wozniak, Apple Co-founder

Got a great game idea? This complete do-it-yourself guide shows you how to make your game idea a reality for the iPhone and iPad. By developing a real game hands-on through the course of this book, you’ll get a thorough introduction to Xcode and Objective-C, while learning how to implement game logic, sophisticated graphics, game physics, sounds, and computer AI.

Steve Wozniak and Todd Moore

Steve Wozniak and Todd Moore

Purchase
Available at Amazon, iBookstore, Barnes & Noble, and O’Reilly Media.

App Store
- Download Paddles game which implements the classic game of pong in 20 lines of code.
- Download Air Hockey which demonstrates complex game logic, graphics, sounds, and computer AI.

Resources
Chapter 2 – Download the Paddles resources which includes the pong sound effects.
Chapter 3,5 – Download the Air Hockey resources which includes the graphics and sounds for Air Hockey.

Source Code
Chapter 1: Introduction to Xcode – Download the Game code which asks math questions.
Chapter 2: Hello Pong – Download the Paddles code which implements the classic game of pong.
Chapter 4: Physics – Download the Touches code which draws circles around multiple touches.
Chapter 3-5: Graphics, Physics, Sounds – Download the AirHockey code which implements two player air hockey.
Chapter 6: Computer AI – Download the AirHockey+AI code code which adds 3 levels of computer difficulty.

 

23 Responses to Book

  1. Michael Hemberger says:

    I just bought the ebook.
    Normally complete project code is made available with these books.
    Do you have any plans on releasing completed code with project?

  2. Agustin says:

    Hi,

    I love your book so far, I’m only in chapter 2, but I’m a bit stuck with the paddle game.
    I am having problems with the following method:

    viewDidLoad

    the error is that both instances for Start and Reset seem to be missing, but I typed them there.

    this is my viewDidLoad code:



    - (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self start];
    [self reset];
    }


    Code for Start and Reset is here:


    - (void)reset
    {
    // set direction of ball to either left or right direction
    if ((arc4random() % 2) == 0) dx = -1; else dx = 1;

    // reverse dy if not 0 as this will send the puck to the
    // player who just scored otherwise set in random direction
    if (dy != 0) dy = -dy;
    else if ((arc4random() %2) == 0) dy = -1; else dy = 1;

    // move point to random position in center
    viewPuck.center = CGPointMake(15 + arc4random() % (320 - 30), 240);

    // reset speed
    speed = 2;
    }
    - (void)start
    {
    if (timer == nil)
    {
    // create our animation timer
    timer = [[NSTimer scheduledTimerWithTimeInterval: 1.0/60.0 target:self selector: @selector(animate) userInfo: NULL repeats: YES] retain];
    }
    // show the puck
    viewPuck.hidden = NO;
    }

    I followed the instructions to the letter (or maybe not since I’m having problems)
    I’m also using the latest Xcode version (free license).

    I’d appreciate any and all help! thanks a lot!

  3. Hans Glitsch says:

    Hi Todd,

    I just finished reading your book “Tap, Move, Shake”. It was a really good, quick, and fun introduction to iphone programming and using xcode. I purchased the kindle version so I could have it on my screen next to xcode as I worked through the chapters. I really like the way you guided the projects in a kind of evolutionary way and built on what was done previously in the book. Your book was a really good way to get my feet wet and get a feel for how things are done. I only skimmed over the last two chapters, but it looks like there’s some really good advice in there — I intend to go back and reread them when I finish my first app.

    Now I need to read something that goes deeper and has more details about objective-c, the ios sdk, best practices, memory management, etc. Btw, I’ve been a c++ developer for over 20 years. Do you have any good book recommendations?

    Thanks,
    Hans

  4. Matas says:

    hi, please fix the 6th chapter source files, because when i click on the 6th chapter files i download files from 3-5chapter.
    Chapter 3-5: Graphics, Physics, Sounds – Download the AirHockey code which implements two player air hockey.
    Chapter 6: Computer AI – Download the AirHockey+AI code code which adds 3 levels of computer difficulty.

  5. Matt says:

    Hi Todd, i bought your book. ;) can you make tutorial without alerts ( tap the screen to play the game)? And game center wins count system?

    • todd says:

      Hi Matt, you could add a UILabel into the view that says “Tap To Start” and then track if the game is playing or not with a boolean. The touch handler could be used to start the game and hide the label. Apple sample code has a great class on managing Game Center interactions so I would start there. Cheers, Todd

  6. Stefan Fröhlich says:

    Hi Todd,

    I’ve downloaded all the sources for the book above.

    Unfortunately, none execept the “touches” example will compile using xCode 4.02/Snow Leopard.
    Here you can see the errors for the AirHockey project.

    Do your sample files require xCode 4.2? What can I do that I don’t get compiler errors on xCode 4.02?

    Thanks for your insights,
    Stefan.

  7. Chris A. says:

    I chose to try and do the first Paddles exercise with Storyboards and ARC. No problems until I need to call the Pause and Stop methods from the PaddlesAppDelegate. I’m guessing since the PaddlesViewController is loaded by the Storyboard, it’s not the same as being loaded in didFinishLaunchingWithOptions? Any ideas how I would do that? Thanks!

  8. Fatso says:

    i downloaded the source for chapter 6, i cant find the AI class inside, did i download the wrong 1?

  9. Stefan Fröhlich says:

    Hi Todd,

    switching to Xcode 4.3.1 there is a problem with your 2 player sources of Air Hockey. It works well on iOS Simulator 5.1, but crashes on iOS Simulator 4.3:

    Here’s the stack trace:
    2012-03-22 18:47:11.580 AirHockey[5018:b903] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key debug.’
    *** Call stack at first throw:
    (
    0 CoreFoundation 0x00fcf5a9 __exceptionPreprocess + 185
    1 libobjc.A.dylib 0x014b8313 objc_exception_throw + 44
    2 CoreFoundation 0x00fcf4e1 -[NSException raise] + 17
    3 Foundation 0x009a1677 _NSSetUsingKeyValueSetter + 135
    4 Foundation 0x009a15e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5 UIKit 0x0041d30c -[UIRuntimeOutletConnection connect] + 112
    6 CoreFoundation 0x00f458cf -[NSArray makeObjectsPerformSelector:] + 239
    7 UIKit 0x0041bd23 -[UINib instantiateWithOwner:options:] + 1041
    8 UIKit 0x0041dab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9 UIKit 0x002d3628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10 UIKit 0x002d1134 -[UIViewController loadView] + 120
    11 UIKit 0x002d100e -[UIViewController view] + 56
    12 UIKit 0x00244d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
    13 UIKit 0x0024422d -[UIWindow _setHidden:forced:] + 303
    14 UIKit 0x0024401d -[UIWindow _orderFrontWithoutMakingKey] + 50
    15 UIKit 0x00242cd1 -[UIWindow makeKeyAndVisible] + 39
    16 AirHockey 0x000021ab -[PaddlesAppDelegate application:didFinishLaunchingWithOptions:] + 571
    17 UIKit 0x00221c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    18 UIKit 0x00223d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    19 UIKit 0x0022e617 -[UIApplication handleEvent:withNewEvent:] + 1533
    20 UIKit 0x00226abf -[UIApplication sendEvent:] + 71
    21 UIKit 0x0022bf2e _UIApplicationHandleEvent + 7576
    22 GraphicsServices 0x01f67992 PurpleEventCallback + 1550
    23 CoreFoundation 0x00fb0944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    24 CoreFoundation 0x00f10cf7 __CFRunLoopDoSource1 + 215
    25 CoreFoundation 0x00f0df83 __CFRunLoopRun + 979
    26 CoreFoundation 0x00f0d840 CFRunLoopRunSpecific + 208
    27 CoreFoundation 0x00f0d761 CFRunLoopRunInMode + 97
    28 UIKit 0x002237d2 -[UIApplication _run] + 623
    29 UIKit 0x0022fc93 UIApplicationMain + 1160
    30 AirHockey 0x00001eaa main + 170
    31 AirHockey 0x00001df5 start + 53
    32 ??? 0×00000001 0×0 + 1
    )
    terminate called throwing an exception(lldb)

    There is a similar problem with the AI version.

    Strange thing is: my personal AI version works! Unfortunately, my 2 player version doesn’t. What’s the problem?

    Thanx for your help,
    Stef.

  10. David Blair says:

    Hi

    When is the book going to be available on the UK iTunes?

    • todd says:

      I’m surprised it isn’t. I’ll check on it.

      • David Blair says:

        I have an app under development which is a folio of design and photography. I have wallpapers, twitter and flickr integration. To help get the app through the review process I want to put in a simple game (such as the air hockey one).

        You have some code in the implentation file. As the game I want to do would be a screen off of the home screen, would I still put the code into the implenation file?

        Sorry if this question makes no sense.

  11. Martin says:

    When the paddles game is running I see the following in the debug area:

    Applications are expected to have a root view controller at the end of application launch

    This only started appearing after the alert message was put into the code to ask the user if they are ready to play.

    How do you get rid of the message?

  12. Martin says:

    I did some searching on the web and found this answer and it worked for me.

    ——————————-
    http://stackoverflow.com/questions/9040896/why-is-showing-a-uialertview-in-applicationdidfinishlaunchingwithoptions-causi

    Try replacing [alert show] with:
    [alert performSelector:@selector(show) withObject:nil afterDelay:0.0];

    This delays the alert for a single pass through the runloop, presumably allowing your app’s controllers and storyboards to complete their setup before the alert is presented.

    • todd says:

      Thanks for the info. Did you create your project with storyboards?

      • Martin says:

        No I didn’t Todd. I followed the directions that you had for creating the Paddles project without storyboards. I don’t know how to use storyboards yet. :)

        I forgot to initially mention that I was using the iOS 5 simulator.

        Everything worked great! On to Graphics now!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>