O'Reilly logo

PhoneGap 3.x Mobile Application Development HOTSHOT by Kerri Shotts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing updates

Of course, drawing the same frame over and over won't do any good. We need to update the game too. This includes responding to user input, checking for collisions, and moving us along the cave.

Getting on with it

We'll be doing all our updating in… guess what—doUpdate in www/js/app/views/gameView.js.

If you recall from the last task, the only incoming parameter is the incoming frame multiplier. We want this to be 1, but it might be 2 if we're getting 30 fps, or 4 if we're getting 15 fps. We'll use the frame multiplier at various points to multiply any updates so that everything moves as if we were getting 60 fps, even when we aren't. Let's use the following code for this purpose:

self._doUpdate = function ( f ) { var gameOver = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required