DebugDrawer.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:libgdxcn 作者:
@Override
public void draw3dText (Vector3 location, String textString) {
    if (spriteBatch == null) {
        spriteBatch = new SpriteBatch();
    }
    if (font == null) {
        font = new BitmapFont();
    }

    // this check is necessary to avoid "mirrored" instances of the text
    if (camera.frustum.pointInFrustum(location)) {
        if (viewport != null) {
            camera.project(location, viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(),
                viewport.getScreenHeight());
        } else {
            camera.project(location);
        }

        shapeRenderer.end();
        spriteBatch.begin();

        // the text will be centered on the position
        TextBounds bounds = font.getBounds(textString);
        font.draw(spriteBatch, textString, location.x - (bounds.width / 2), location.y + (bounds.height / 2));

        spriteBatch.end();
        shapeRenderer.begin(ShapeType.Line);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号