矢量位置的游戏精灵渲染错误

时间:2014-06-17 07:00:48

标签: android eclipse opengl-es nullpointerexception libgdx

以下是我的游戏错误日志。但无法找出原因。

06-17 13:39:19.458: E/EGL_SERVER(5773): pid mem_get_free_space before =  3ff7c0
06-17 13:39:19.458: E/EGL_SERVER(5773): pid mem_get_free_space =  3ff7c0
06-17 13:39:19.552: W/dalvikvm(5773): threadid=9: thread exiting with uncaught exception (group=0x40018578)
06-17 13:39:19.552: E/AndroidRuntime(5773): FATAL EXCEPTION: GLThread 10
06-17 13:39:19.552: E/AndroidRuntime(5773): java.lang.NullPointerException
06-17 13:39:19.552: E/AndroidRuntime(5773):     at com.badlogic.androidgames.trialmazegame.WorldRender.renderPix(WorldRender.java:34)
06-17 13:39:19.552: E/AndroidRuntime(5773):     at com.badlogic.androidgames.trialmazegame.Gameplay.renderRunning(Gameplay.java:160)
06-17 13:39:19.552: E/AndroidRuntime(5773):     at com.badlogic.androidgames.trialmazegame.Gameplay.present(Gameplay.java:137)
06-17 13:39:19.552: E/AndroidRuntime(5773):     at com.badlogic.androidgames.framework.impl.GLGame.onDrawFrame(GLGame.java:95)
06-17 13:39:19.552: E/AndroidRuntime(5773):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1388)
06-17 13:39:19.552: E/AndroidRuntime(5773):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)

这是我的renderPix()代码:

public void setSize (int w, int h) {
    this.width = w;
    this.height = h;
    ppuX = (float)width / CAMERA_WIDTH;
    ppuY = (float)height / CAMERA_HEIGHT;
}

public WorldRender(World world) {
    this.world = world;
    this.cam = new Camera2D(glGraphics, CAMERA_WIDTH, CAMERA_HEIGHT);
    this.pixPlayer = world.getPixPlayer();
}

public void renderPix(){
    batcher.drawSprite(pixPlayer.getPosition().x * ppuX, pixPlayer.getPosition().y * ppuY, PixPlayer.size * ppuX, PixPlayer.size * ppuY, Assets.player);
}

这是PixPlayer更新位置。我认为没关系。但是当它在我的Android手机上发布时,它突然关闭了。

public void update(float delta) {
    stateTime += delta;
    position.add(getVelocity().x * delta, getVelocity().y * delta);
    if( position.x < 0 ) {
        position.x = 0;
        velocity.x = 0;
        state = PixState.Idle;
    if( position.y < 0 ) {
        position.y = 0;
        velocity.y = 0;
        state = PixState.Idle;
    }
    x = position.x;
    y = position.y;
    }
}
直到现在,这让我感到不安。

0 个答案:

没有答案