Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将车身连接到SpriteBatch上_Java_Android_Libgdx_Box2d_Spritebatch - Fatal编程技术网

Java 将车身连接到SpriteBatch上

Java 将车身连接到SpriteBatch上,java,android,libgdx,box2d,spritebatch,Java,Android,Libgdx,Box2d,Spritebatch,我想画一个雪碧拍来同步身体的位置。 我不确定这是否是正确的方法来做这件事,在安德林你会只使用物理连接器,但我试图在身体存储的位置绘制精灵 Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); elapsedTime += Gdx.graphics.getDeltaTime(); batch.setProjectionMat

我想画一个雪碧拍来同步身体的位置。 我不确定这是否是正确的方法来做这件事,在安德林你会只使用物理连接器,但我试图在身体存储的位置绘制精灵

    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();

    elapsedTime += Gdx.graphics.getDeltaTime();

    batch.setProjectionMatrix(camera.combined);

    batch.begin();

    batch.draw(walkAnimation.getKeyFrame(elapsedTime, true), 
    mrsaiBody.getPosition().x, mrsaiBody.getPosition().y, width/2, height/2);

    batch.end();
    mWorld.step(1/30f, 6, 2);
    mRenderer.render(mWorld, camera.combined);

我的问题是,在屏幕上我看到了Saibody先生的形状和我做的地面。当形状与地面接触时,x和y值仍然受重力影响,即使形状不受重力影响。当我使用batch.draw时,如何使此形状的当前位置与位置匹配?

据我所知,getPosition将为您提供身体的实际位置。可能您在某个时候停止调用debugRenderer,或者您正在跟踪与碰撞的实体不同的实体。如果不是这样的话,渲染函数中的更多代码会有所帮助。嗯,我似乎定义了mrsaibody两次。我一定是在追踪另一具尸体