diff options
author | Laurent Bernabe <laurent.bernabe@gmail.com> | 2014-01-27 18:24:11 (GMT) |
---|---|---|
committer | Laurent Bernabe <laurent.bernabe@gmail.com> | 2014-01-27 18:24:11 (GMT) |
commit | bbe4dd2758d86b37edf10a08f240b09ef6eb8cc9 (patch) | |
tree | 74baf8c6e7ae14e94fa869e87d235c2c59e3e15c | |
parent | b94b0e7e9261799d9017b1eb922b7474ae09e895 (diff) |
Now all chess pictures are loaded.
-rw-r--r-- | js/activity.js | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/js/activity.js b/js/activity.js index 805861a..fe88491 100644 --- a/js/activity.js +++ b/js/activity.js @@ -31,16 +31,44 @@ define(function (require) { var background = new createjs.Shape(); background.graphics.beginFill("#CCC").drawRect(0, 0, gameZone_dim[0], gameZone_dim[1]); + // Load images asynchronously + var piecesImages = {}; var loadingQueue = new createjs.LoadQueue(false); + loadingQueue.on("fileload", handleFileLoaded); loadingQueue.on("complete", handleLoadingComplete); loadingQueue.loadManifest([ - {id:"wb", src:"../pictures/wb.png"} + {id:"wp", src:"../pictures/wp.png"}, + {id:"wn", src:"../pictures/wn.png"}, + {id:"wb", src:"../pictures/wb.png"}, + {id:"wr", src:"../pictures/wr.png"}, + {id:"wq", src:"../pictures/wq.png"}, + {id:"wk", src:"../pictures/wk.png"}, + {id:"bp", src:"../pictures/bp.png"}, + {id:"bn", src:"../pictures/bn.png"}, + {id:"bb", src:"../pictures/bb.png"}, + {id:"br", src:"../pictures/br.png"}, + {id:"bq", src:"../pictures/bq.png"}, + {id:"bk", src:"../pictures/bk.png"} ]); + function handleFileLoaded(file){ + var image = new createjs.Bitmap(file.item.src); + image.scaleX = 0.1; + image.scaleY = 0.1; + piecesImages[file.item.id] = image; + } + function handleLoadingComplete(){ - console.log("loaded image"); - var image = loadingQueue.getResult("wb").result; - stage.addChild(new createjs.Bitmap(image)); + var img1 = piecesImages["wb"].clone(); + img1.x = 20; + img1.y = 20; + stage.addChild(img1); + + var img2 = piecesImages["wb"].clone(); + img2.x = 60; + img2.y = 20; + stage.addChild(img2); + stage.update(); } |