EaselJS StageGL:文本不起作用(但使用 Stage canvas)
EaselJS StageGL: text not working (but does using Stage canvas)
我重新编写了一个 HTML5 游戏(使用 createJS)以匹配 StageGL,但结果所有文本字段都消失了。切换回 Stage 解决了这个特定问题(参见下面的代码示例)。
有谁知道解决这个问题的方法吗?
示例代码:
canvas.width = stageWidth;
canvas.height = stageHeight;
stage = new createjs.StageGL(canvas); // <= text does not work with GL???
stage = new createjs.Stage(canvas); // <= text works fine
var textTest = new createjs.Text("Hello World");
textTest.x = 10;
textTest.y = 20;
stage.addChild(textTest);
提前感谢您的评论!
如果不缓存文本将无法工作,因为 Text/Vector canvas API 不受 StageGL 支持。
缓存非常简单:
var bounds = text.getBounds();
text.cache(bounds.x, bounds.y, bounds.width, bounds.height);
当文本更改时,您将需要重新缓存文本。
干杯,
我重新编写了一个 HTML5 游戏(使用 createJS)以匹配 StageGL,但结果所有文本字段都消失了。切换回 Stage 解决了这个特定问题(参见下面的代码示例)。 有谁知道解决这个问题的方法吗?
示例代码:
canvas.width = stageWidth;
canvas.height = stageHeight;
stage = new createjs.StageGL(canvas); // <= text does not work with GL???
stage = new createjs.Stage(canvas); // <= text works fine
var textTest = new createjs.Text("Hello World");
textTest.x = 10;
textTest.y = 20;
stage.addChild(textTest);
提前感谢您的评论!
如果不缓存文本将无法工作,因为 Text/Vector canvas API 不受 StageGL 支持。
缓存非常简单:
var bounds = text.getBounds();
text.cache(bounds.x, bounds.y, bounds.width, bounds.height);
当文本更改时,您将需要重新缓存文本。
干杯,