HTML and CSS Reference
In-Depth Information
Integrating BS Bingo into the Project
We are now going to copy code from the
BSBingo.html
file we created earlier into the
index.html
file in our project.
First we will copy our JavaScript include files and add them under the
phonegap.js
script
include. We will not need the
modernizer.js
file, as we will assume the iOS platform
can use HTML5 Canvas:
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script src="TextButton.js"></script>
<script src="ConsoleLog.js"></script>
The
phonegap.js
file should already be included in the www folder, along with
index.html
. It is part of the project template and is needed for all PhoneGap iOS
applications.
Next, we will need to add the call to start our application into the
deviceReady()
function:
/*When this function is called, PhoneGap has been initialized and is ready to roll*/
function onDeviceReady()
{
// do your thing!
canvasApp();
}
We can now replace the rest of the
script
code in the file with our code.
At this step, don't replace from the
<body>
tag down to the end of the
<html>
. Just add the game code inside the
<script>
tags. You can use
the existing
<script></script>
tags; if you do, be careful not to copy
them from
BSBingo.html
.
Make sure that the first few lines look like this because we are removing the check for
Canvas support:
function canvasApp(){
theCanvas = document.getElementById("canvas");
context = theCanvas.getContext("2d");
var bingoCard = [];
var buttons = [];
var standardJargonList = [];
var tempButton = {};
var clickSound;