Skip to content

Commit e50845a

Browse files
author
Lanny McNie
committed
Fixed BitmapText demo.
Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent fb48627 commit e50845a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

examples/BitmapText.html

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,20 @@
4343
stage = new createjs.Stage("testCanvas");
4444

4545
var img = new Image();
46-
img.src = "assets/BitmapFont.png";
4746
img.onload = function() {
47+
var ss = new createjs.SpriteSheet(data);
48+
49+
text = new createjs.BitmapText("Hello World,\nWhat's Happening?", ss);
50+
51+
// Center the text
52+
var bounds = text.getBounds();
53+
text.x = stage.canvas.width - bounds.width >> 1;
54+
text.y = stage.canvas.height - bounds.height >> 1;
55+
56+
stage.addChild(text);
4857
stage.update();
4958
};
59+
img.src = "assets/BitmapFont.png";
5060

5161
// Embedded SpriteSheet data.
5262
var data = {
@@ -116,17 +126,6 @@
116126
[966, 2, 9, 10, 0, -17, -31]
117127
]
118128
};
119-
var ss = new createjs.SpriteSheet(data);
120-
121-
text = new createjs.BitmapText("Hello World,\nWhat's Happening?", ss);
122-
123-
// Center the text
124-
var bounds = text.getBounds();
125-
text.x = stage.canvas.width - bounds.width >> 1;
126-
text.y = stage.canvas.height - bounds.height >> 1;
127-
128-
stage.addChild(text);
129-
stage.update();
130129
}
131130

132131
</script>

0 commit comments

Comments
 (0)