HTML and CSS Reference
In-Depth Information
try
try
{
console
.
log
(
message
);
}
catch
catch
(
exception
) {
return
return
;
}
}
function
function
canvasSupport
() {
return
return
Modernizr
.
canvas
;
}
DragAndDrop.js
DragAndDrop.js
is the main class for the drag-and-drop application. It acts as the controller
for all the other code and classes we have already created.
The first things we do in
DragAndDrop.js
are as follows:
1. Check for Canvas support using the new function in
GameUtilities.js
.
2. Get a reference to the Canvas context (
theCanvas
).
We would begin to define this class as follows:
function
function
DragAndDrop
() {
iif
(
!
canvasSupport
()) {
return
return
;
}
var
var
theCanvas
=
document
.
getElementById
(
"canvasOne"
);
var
var
context
=
theCanvas
.
getContext
(
"2d"
);
...(
code goes here
)...
}
Next, we begin to create properties that we will use to create the application:
var
var
backGround
;
var
var
bulbColors
=
new
new
Array
(
"red"
,
"blue"
,
"green"
,
"yellow"
,
"orange"
,
"pink"
,
"purple"
);
var
var
bulbs
;
backGround
Holds the background image (a black field with snow and a Christmas tree)