在libGDX Scene2D的UI方面,构建游戏中心/玩游戏类型排行榜的最佳方法是什么?

时间:2017-12-01 10:14:37

标签: libgdx scene2d

我正在尝试使用Scene2D在我的libGDX项目中为排行榜构建用户界面。 我的基准测试类似于Google Play游戏/游戏中心排行榜。有点像现有屏幕上的叠加,使用向下滑动的刷新能力。

我对如何更新已渲染的Scene2D元素中的数据没有任何想法。 这就是我创建排行榜的方式。按下按钮调用以下功能。现在如何在刷新时更新下面呈现的排行榜表中的数据?同样的挑战是我试图将排行榜类型从全球变为社交或从上个星期到上周。

mScannerView = new ZBarScannerView(this) {
        /**
         * this will alter the scanning area
         **/
        @Override
        protected IViewFinder createViewFinderView(Context context) {
            return new CustomViewFinderView(context);
        } 
    };



private class CustomViewFinderView extends ViewFinderView {
    Context context;

    public CustomViewFinderView(Context context) {
        super(context);
        this.context = context;
        setLaserEnabled(true);
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (getFramingRect() != null) {
            updateFrameRect();
            setBorderColor(ContextCompat.getColor(context, R.color.colorPrimary));
        }
    }

    private void updateFrameRect() {
        Point viewResolution = new Point(this.getWidth(), this.getHeight());
        int height = (int) ((float) this.getHeight());
        int width = (int) ((float) this.getWidth());

        int leftOffset = (viewResolution.x - width) / 2;
        int topOffset = (viewResolution.y - height) / 2;

        getFramingRect().left = leftOffset;
        getFramingRect().top = topOffset;
        getFramingRect().right = leftOffset + width;
        getFramingRect().bottom = topOffset + height;
    }
}

1 个答案:

答案 0 :(得分:0)

您需要重新创建表格。没有很好的方法在scene2d表中插入/编辑