BitmapText就是用SpriteSheet中定义的图片来显示相应的文字,构造函数如下
BitmapText ([text=""] [spriteSheet=null] )
有两个参数,都是可选的
text表示要显示的文字,spriteSheet是使用的spriteSheet
这两个值也都可以通过相应的属性来设置
bitmapText.spriteSheet=spriteSheet;
bitmapText.text="test";
我把官方的例子copy了一下,代码有点长,但大部分都是数据,关键的只有几行。
这个是官方例子使用的文字图片。
window.onload=init;
var canvas;
var canvasWidth;
var canvasHeight;
var stage;
function init()
{
console.log("init");
canvas=document.getElementById("myCanvas");
canvasWidth=canvas.width;
canvasHeight=canvas.height;
stage =new createjs.Stage(canvas);
createjs.Ticker.timingMode=createjs.Ticker.RAF;
createjs.Ticker.addEventListener("tick",stage);
var data = {
"animations": {
"V": {
"frames": [21]},
"A": {
"frames": [0]},
",": {
"frames": [26]},
"W": {
"frames": [22]},
"B": {
"frames": [1]},
"X": {
"frames": [23]},
"C": {
"frames": [2]},
".": {
"frames": [29]},
"Y": {
"frames": [24]},
"D": {
"frames": [3]},
"Z": {
"frames": [25]},