Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/customs/pieces_bitmaps_manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/customs/pieces_bitmaps_manager.js')
-rw-r--r--lib/customs/pieces_bitmaps_manager.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/customs/pieces_bitmaps_manager.js b/lib/customs/pieces_bitmaps_manager.js
new file mode 100644
index 0000000..c109b70
--- /dev/null
+++ b/lib/customs/pieces_bitmaps_manager.js
@@ -0,0 +1,39 @@
+var PiecesBitmapsManager = Class.create();
+PiecesBitmapsManager.prototype = {
+ // pictures_size : pictures size px
+ // loadingCompleteHandler : a function without any argument and returning nothing.
+ initialize: function(pictures_size, loadingCompleteHandler){
+ this.picturesSize = pictures_size;
+ this.piecesImages = {};
+ this.loadingQueue = new createjs.LoadQueue(false);
+ this.loadingQueue.on("fileload", this.handleFileLoaded, this);
+ this.loadingQueue.on("complete", loadingCompleteHandler, this);
+ },
+ handleFileLoaded : function(file){
+ var image = new createjs.Bitmap(file.item.src);
+ image.scaleX = this.picturesSize/1000.0;
+ image.scaleY = this.picturesSize/1000.0;
+ this.piecesImages[file.item.id] = image;
+ },
+ loadPictures: function() {
+ this.loadingQueue.loadManifest([
+ {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"}
+ ]);
+ },
+
+ // e.g wb for white bishop, bn for black knight.
+ getPicture: function(id){
+ return this.piecesImages[id];
+ }
+}; \ No newline at end of file