Game Development Reference
In-Depth Information
function preload() {
queue = new createjs.LoadQueue();
queue.addEventListener("complete", init);
queue.loadManifest([
{id:"shell", src:"img/card.png"},
{id:"back", src:"img/back.png"},
{id:"garlic", src:"img/garlic.png"},
{id:"onion", src:"img/onion.png"},
{id:"pepper", src:"img/pepper.png"},
{id:"potato", src:"img/potato.png"},
{id:"spinach", src:"img/spinach.png"},
{id:"tomato", src:"img/tomato.png"}
]);
}
function init() {
stage = new createjs.Stage(document.getElementById('canvas'));
startGame();
buildCards();
shuffleCards();
dealCards();
}
function buildCards() {
var i, card, card2, bmp, label, face;
for (i = 0; i < faces.length; i++) {
card = new createjs.Container();
bmp = new createjs.Bitmap(queue.getResult('shell'));
bmp.shadow = new createjs.Shadow("#666", 3, 3, 5);
card.regX = bmp.image.width / 2;
card.regY = bmp.image.height / 2;
card.addChild(bmp);
face = faces[i];
bmp = new createjs.Bitmap(queue.getResult(face));
bmp.regX = bmp.image.width / 2;
bmp.regY = bmp.image.height / 2;
bmp.x = card.regX;
bmp.y = 70;
card.addChild(bmp);
label = new createjs.Text(faces[i].toUpperCase(), "20px Arial", "#009900");
label.textAlign = 'center';
label.x = card.regX;
label.y = 144;
card.addChild(label);
bmp = new createjs.Bitmap(queue.getResult('back'));
bmp.name = 'back';
card.addChild(bmp);
card2 = card.clone(true);
card.key = card2.key = faces[i];
cards.push(card, card2);
}
}
Search WWH ::




Custom Search