Createjs 为游戏创建定时器时钟

Createjs create timer clock for game

请问有人知道在 Createjs 中创建定时器时钟的最佳方法吗?我知道我可以在 html 中做一些事情并用 DOMElement 引用它,但我在过去让它工作时遇到了一些噩梦?基本上我需要在容器中显示一个计时器,这样玩我的游戏的人就可以看到他们完成一个关卡需要多长时间——非常标准的东西。

更好的是,如果我能让它在我的位图文本中使用字体,那就太好了。任何帮助将不胜感激!

只需在 JS 中跟踪时间,并将其输出到 BitmapText 元素。

var startTime = (new Date()).getTime();

// in your update loop:
currentTime = (new Date()).getTime();
var time = Math.floor((currentTime-startTime)/1000);
myBitmapText.text = time + "s";