如何为PlayN HTML / DOM呈现文本字符串

时间:2012-07-27 09:16:52

标签: playn

我正在尝试使用PlayN Showcase应用程序中的方法绘制一些文本:

protected static Layer createTextLayer(TextLayout layout, int color) {
    CanvasImage image = graphics().createImage((int) Math.ceil(layout.width()), (int) Math.ceil(layout.height()));
    image.canvas().setFillColor(color);
    image.canvas().fillText(layout, 0, 0);
    return graphics().createImageLayer(image);
}

它适用于HTML / Canvas,但不适用于HTML / Dom。

1 个答案:

答案 0 :(得分:0)

尝试使用tripleplay(https://github.com/threerings/tripleplay)。也许它会有所帮助。

Label label = new Label("MY LABEL");
Interface iface = new Interface();
Stylesheet rootSheet = Stylesheet.builder().create();
Root nameroot = iface.createRoot(AxisLayout.horizontal().gap(300), rootSheet);
nameroot.add(label);
nameroot.setSize(100, 30);
nameroot.setStyles(Styles.make(Style.HALIGN.left));
PlayN.graphics().rootLayer().add(nameroot.layer);