我正在使用box2D渲染来查看我的图形(我尝试使用纹理,并得到完全相同的结果)我的渲染代码如下:
public void render()
{
long startTime = System.nanoTime();
world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);
float updateTime = (System.nanoTime() - startTime) / 1000000000.0f;
startTime = System.nanoTime();
float renderTime = (System.nanoTime() - startTime) / 1000000000.0f;
GL10 gl = Gdx.app.getGraphics().getGL10();
camera.update();
camera.apply(gl);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
renderer.render(world, camera.combined);
batch.begin();
font.setScale(0.020f);
font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond() + ", update: " + updateTime + ", render: " + renderTime, 0,
20);
batch.end();
}
在桌面版本上可以正常工作并显示它应该。
然而,当我在手机上启动它时,我得到了这个,这不是我想要的:
正如你所看到的那样,它被压扁只能占据屏幕的顶部。
libgdx中是否有错误或者我错过了什么?
编辑:完整的创建代码:
Vector2 pouchPos = new Vector2(0, -12);
slingshotListener = new SlingshotListener(pouchPos);
batch = new SpriteBatch();
camera = new OrthographicCamera(32, 48);
Gdx.input.setInputProcessor(slingshotListener);
font = new BitmapFont();
renderer = new Box2DDebugRenderer();
world = new World(new Vector2(0, -10), true);
BodyDef bd = new BodyDef();
ground = world.createBody(bd);
EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-16, -20), new Vector2(16, -20));
FixtureDef fd = new FixtureDef();
fd.shape = shape;
ground.createFixture(fd);
shape.dispose();
Misc.createLine(new Vector2(-3, -16), pouchPos, camera, world).setSensor(true);
Misc.createLine(new Vector2(3, -16), pouchPos, camera, world).setSensor(true);
pic = new Texture(Gdx.files.internal("pong/ball.png"));
答案 0 :(得分:0)
我把它放在AndroidManifest.xml中,似乎解决了这个问题:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />