HTML and CSS Reference
In-Depth Information
Figure 7-10: Logging an object to the console.
NOTE console.log isn't supported on all browsers, and on some older browsers it's available only
when developer tools are enabled. It can slow down your game if you call it frequently, so make sure you re-
move any calls before publishing your game.
Lastly, and perhaps most important, you can use the console to execute arbitrary JavaScript and examine ob-
jects while your game runs.
Anything you type into the console executes when you press Enter/Return, meaning if you add a JavaScript
function to your game, you can use it from the console. This is useful for things such as turning on a developer
mode, adding health to make your game easier to test, and jumping to arbitrary points in your game. Using Alien
Invasion as an example, you can test starting the game or showing the “you lose” screen which normally plays
after you get hit by an enemy by executing the appropriate method from the console (see Figure 7-11 ) .
Search WWH ::

Custom Search