Game Development Reference
In-Depth Information
Tips and Tricks for Running Your Game on Windows 8
In most cases, setting up your game should be as easy as copying over the files, including
them in the project, and hitting compile. If you are running into issues or want to better un-
derstand what is going on under the hood to help refactor or clean things up, I'll go over
some techniques to help you debug your game in Visual Studio.
Disable Touch Behaviors via CSS
You may notice that pinch to zoom or double tap to zoom may happen in games you move
over to Windows 8 from the Web. The quickest way to solve this is with the following CSS:
-ms-touch-action: none;
You can place this in the HTML, body, or Canvas element CSS to disable touch behaviors.
File Paths and Loading Locally
File paths are resolved to the root of your project when it is running. So, if you wanted to
load an image from the images folder, you can simply do:
<img src="/images/name-of-image.png"/>
Likewise, you can do the same when loading images or assets dynamically via JavaScript.
Hopefully you won't have to make a single change to a file path or resource.
In the end, you should have all the tools you need to quickly figure out what may be going
wrong with your game's code. Over the next few chapters, I'll discuss what you can do to en-
hance your game on Windows 8 and better integrate it with WinJS.
Avoid Modernizr Libraries
If your game is already running on the Web, you may be making use of some kind of
Modernizr or some type of polyfill to help get your game running across each of the different
browsers. While this works great for the Web, you will want to remove this library if it gives
you problems. I have seen Visual Studio throw errors if the library violates Windows 8's
JavaScript sandbox by trying to inject live code into the DOM at runtime.
Search WWH ::




Custom Search