小编Ash*_*leh的帖子

java中〜和++的优先级

考虑这段代码

int j = 7;
System.out.println(Integer.toBinaryString(j));
j = ~j++;
System.out.println(Integer.toBinaryString(j));
Run Code Online (Sandbox Code Playgroud)

版画

111
11111111111111111111111111111000
Run Code Online (Sandbox Code Playgroud)

我期待看到的

111
11111111111111111111111111111001
Run Code Online (Sandbox Code Playgroud)

首先我认为它可能是〜和++的优先级

如果在++之前评估〜,答案就是

11111111111111111111111111111001
Run Code Online (Sandbox Code Playgroud)

否则,如果在〜之前评估++

11111111111111111111111111110111
Run Code Online (Sandbox Code Playgroud)

我搜索了Oracle教程,但我找不到答案.谁能解释这种行为?

java operators bitwise-operators logical-operators

7
推荐指数
1
解决办法
172
查看次数

libgdx 中的距离场字体

我正在尝试渲染平滑的可缩放位图字体。检查此问题后,使用距离场字体提到的答案之一。

我正在按照LibGDX wiki 文章中关于距离归档字体的方式进行操作。但是我无法让它工作。字体变得模糊。

示例预览

这是我用来生成此输出的代码

public class FontRenderTest implements ApplicationListener {
private Texture texture;
private SpriteBatch spriteBatch;
private BitmapFont font;

@Override
public void create() {
    spriteBatch = new SpriteBatch();

    Texture texture = new Texture(Gdx.files.internal("Raleway.png"), true); // true enables mipmaps
    texture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear); // linear filtering in nearest mipmap image

    font = new BitmapFont(Gdx.files.internal("Raleway.fnt"), new TextureRegion(texture), false);
}


@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    spriteBatch.begin();
    font.draw(spriteBatch, "This is hazy !!", 100, 150); …
Run Code Online (Sandbox Code Playgroud)

libgdx

4
推荐指数
1
解决办法
1375
查看次数