From 307b0f7e265b22181c6362c162c068806505cff2 Mon Sep 17 00:00:00 2001 From: Laurent Bernabe Date: Thu, 20 Mar 2014 22:33:57 +0000 Subject: Now I avoid creating new Text object whenever I need to change the textbox content. --- diff --git a/js/activity.js b/js/activity.js index 4a1702a..2078c17 100644 --- a/js/activity.js +++ b/js/activity.js @@ -89,6 +89,7 @@ define(function (require) { textZone.changeTextTo("Here the white bishop can eat the black "+ "queen, because the black queen is on the bishop diagonal !"); + textZone.changeTextTo("Done !"); var img1 = piecesImages.wb.clone(); img1.x = graphicalBoard.getFileX(2); diff --git a/lib/customs/graphical_board.js b/lib/customs/graphical_board.js index 57df226..a6ca655 100644 --- a/lib/customs/graphical_board.js +++ b/lib/customs/graphical_board.js @@ -25,6 +25,7 @@ GraphicalBoard.prototype = { getRankY: function(rank){ return this.pos[1] + (7-rank) * this.cellSize; }, + // Just call it once. addToStage: function(){ for (var rank = 0; rank < 8; rank++){ for (var file = 0; file < 8; file++){ diff --git a/lib/customs/textzone.js b/lib/customs/textzone.js index 386cd47..c1a34d9 100644 --- a/lib/customs/textzone.js +++ b/lib/customs/textzone.js @@ -15,6 +15,7 @@ TextZone.prototype = { this.stage.addChild(this.text); this.stage.update(); }, + // Just call it once. addToStage: function(){ var txtZone = new createjs.Shape(); txtZone.graphics.beginFill(this.backgroundColor).drawRect( @@ -26,7 +27,7 @@ TextZone.prototype = { changeTextTo: function(newText){ this.stage.removeChild(this.text); - this.text = new createjs.Text(newText, this.fontStr, this.textColor); + this.text.text = newText; this.text.lineWidth = this.width; this.text.x = this.x; this.text.y = this.y; -- cgit v0.9.1