HTML and CSS Reference
In-Depth Information
Notice that we have removed this set of code:
if (!canvasSupport()) {
return;
}else{
theCanvas = document.getElementById("canvas");
context = theCanvas.getContext("2d");
}
We have replaced it with just the following since we no longer need to check whether
the device can use the canvas (we must assume it can):
theCanvas = document.getElementById("canvas");
context = theCanvas.getContext("2d");
We have also deleted the canvasSupport() function, as it is not needed. We will next
copy the rest of the code, including our HTML, and replace everything in the
index.html file.
We need to make sure that the current opening <body> tag remains in index.html . It
should look like this:
</head>
<body onload="onBodyLoad()">
The next step is to replace the rest of the file with HTML code from BSBingo.html :
<div style="position: absolute; top: 0px; left: 0px;">
<canvas id="canvas" width="570" height="418">
Your browser does not support HTML5 Canvas.
</canvas>
<audio id ="clicksound" preload="auto">
<source src="click.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
</div>
</body>
</html>
We now have enough code to do a preliminary test of our game in the simulator.
We will first need to move our files into the project folder. Take TextButton.js ,
ConsoleLog.js , and click.mp3 and move them to the www folder on the disk. The project
in Xcode will now reflect the new files, as seen in Figure 10-10 .
Search WWH ::




Custom Search