Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bernabe <laurent.bernabe@gmail.com>2014-03-20 22:33:57 (GMT)
committer Laurent Bernabe <laurent.bernabe@gmail.com>2014-03-20 22:33:57 (GMT)
commit307b0f7e265b22181c6362c162c068806505cff2 (patch)
tree55e026541ba49582ded5a97705cd0018933bc83e
parentcbc53de61019293f742680fd7062f212be7bc91b (diff)
Now I avoid creating new Text object whenever I need to change the textbox content.
-rw-r--r--js/activity.js1
-rw-r--r--lib/customs/graphical_board.js1
-rw-r--r--lib/customs/textzone.js3
3 files changed, 4 insertions, 1 deletions
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;