找到你要的答案

Q:Shape Renderer Increasing Square Size Not Uniform

Q:形状大小不均匀的渲染增加广场

So I have an actor object I extended that will either draw a square or a circle, every frame it increases in size by 0.1.

When I draw circle it increases in size correctly and grows on screen, however when I draw a rect it jumps in size every 2.0 increments. I was wondering if anyone else had seen this behaviour.

Here is the simple code I use to draw the shapes.

  float size = 10.0f;

    @Override
    public void draw(Batch batch, float parentAlpha) {

        super.draw(batch, parentAlpha);

        ShapeRenderer r = new ShapeRenderer();

        r.begin(ShapeRenderer.ShapeType.Filled);
        r.setColor(Color.RED);

        //r.circle(this.getX() - (size / 2), this.getY() - (size / 2), size);  //this increases correctly
        r.rect(this.getX() - (size / 2), this.getY() - (size / 2), size, size);  //this doesnt

        r.end();

        size += 0.1f;

    }

So you can see what I mean I took some vids:

Circle : https://youtu.be/TtLcMxUCKb0

Square : https://youtu.be/UUGNfSpotKo

所以我有一个演员对象我扩展,要么画一个正方形或一个圆圈,每帧增加0.1的大小。

当我画它增加的大小和生长在屏幕上正确,但是当我画一个矩形它跳跃的大小每2增量。我想知道是否有其他人见过这种行为。

这里是我用来绘制形状的简单代码。

  float size = 10.0f;

    @Override
    public void draw(Batch batch, float parentAlpha) {

        super.draw(batch, parentAlpha);

        ShapeRenderer r = new ShapeRenderer();

        r.begin(ShapeRenderer.ShapeType.Filled);
        r.setColor(Color.RED);

        //r.circle(this.getX() - (size / 2), this.getY() - (size / 2), size);  //this increases correctly
        r.rect(this.getX() - (size / 2), this.getY() - (size / 2), size, size);  //this doesnt

        r.end();

        size += 0.1f;

    }

所以你会明白我的意思,我拍了一些视频:

圈:https://youtu.be/ttlcmxuckb0

正方:https://youtu.be/uugnfspotko

answer1: 回答1:

Seems to me like the square is expanding the least amount it can, 1 pixel at a time, it just looks a bit different from the circle since the circle does more than just expand 1 pixel to each side It has to the circle always look as round as possible, so updates a bit more often, shifting around a few pixel but not expanding.

我觉得广场扩大可以最少,1像素的时候,它看起来有点不同,因为从圆圈不仅仅是扩大1像素每侧有圆总是圆的可能,所以更新多一点的时候,拨几像素周围但不扩大。

android  libgdx