Game Development Reference
In-Depth Information
Chapter 5. Debugging and
Optimization
One of the most rewarding parts about building HTML5 games for Windows 8 is the fact
that, if your game is already running in the browser on the desktop, chances are good that it
will run perfectly as a Windows Store app. Of course, in the real world, nothing works ex-
actly like you expect it to. This chapter will go over some of the best ways to optimize your
game so that it runs well on your computer and all the other Windows 8 devices out there.
Using the Console
If you are a fan of console.log(), you'll be happy to know that all of your log traces will still
show up in Visual Studio's console window. This means the quickest way to debug your app
is probably to throw a console.log() statement in there and see what's happening. There are a
few things that Visual Studio doesn't support in the console output, which you may be used
to in a browser log window:
▪ Visual Studio will not output the structure of an object. This means you simply get a
string equivalent of the object. For exploring objects, you will need to use the debugger
and a breakpoint, which we will talk about next.
▪ The console also doesn't automatically add spaces to multiple items separated by a
comma. So, if you do console.log(“show”, “me”, “this”) in the console, you will
see “showmethis.” In WebKit browsers, the console would give you “show me this.” It's
not a deal breaker but something to keep in mind if you spend a lot of time trying to out-
put multiple items in a single log statement.
Finally, the most important feature of the console is the ability to execute code or modify val-
ues while your app is running. Simply type into the console window and you will be able to
test code by hand, just like you would do in a browser's console window.
Search WWH ::




Custom Search