我做一個簡單的Java遊戲,因爲我的一部分,它性學習的,當我運行它,我得到一個:的NullPointerException在libgdx(Java)的重疊
Exception in thread "LWJGL Application" java.lang.NullPointerException at com.mattihase.floatingpoint.GameScreen.generalUpdate(GameScreen.java:65) at com.mattihase.floatingpoint.GameScreen.render(GameScreen.java:42) at com.badlogic.gdx.Game.render(Game.java:46) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:207) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
這是一般更新線就在談論和它下面的直線:
if(pc.bounds.overlaps(gary.Rbounds))
//where i test a bunch of booleans to see what the dialog returned should be
//yes, i know i'm probably doing the ifs it unoptimized but i couldn't get it to
//work the other way.
//the pc.bounds stuff is there to make it follow the player character around the
//world as the camera already does this.
{
if(pc.onquest = false){
if(pc.finishquest = false){
Assets.font.draw(batch, gary.Gdio, pc.bounds.x - 250, pc.bounds.y - 190);
pc.onquest = true;
}
}
if(pc.onquest = true){
if(pc.finishquest = false){
Assets.font.draw(batch, gary.GDdio, pc.bounds.x - 250, pc.bounds.y - 190);
}
}
if(pc.haspoints = true){
pc.finishquest = true;
}
if(pc.finishquest = true);
Assets.font.draw(batch, gary.GCdio, pc.bounds.x - 250, pc.bounds.y - 190);
pc.onquest = false;
pc.award = true;
}`
和這些都爲playercharacter和NPC(稱爲PC(類playerCharacter)和加里類(CLA SS Rectoid)分別) 玩家角色
public Sprite image;
public Rectangle bounds;
public int score;
public String scoreprint;
public boolean onquest;
public boolean finishquest;
public boolean haspoints;
public boolean award;
public PlayerCharacter(){
onquest = false;
haspoints = false;
finishquest = false;
award = false;
score = 0;
image = Assets.s_pc;
bounds = new Rectangle(256-16, 192-16, 16, 16);
scoreprint = score + "";`
和加里 '公共雪碧銳美; public Rectangle Rbounds; public String Gdio; public String GDdio; public String GCdio;
public Rectoid()
{
Rimage = Assets.s_rectoid;
Rbounds = new Rectangle(1024, 64, 64, 32);
Gdio = "the diolog";
GDdio = "the diolog";
GCdio = "the diolog";`
Ç
您是否知道像'pc.onquest = false'這樣的句子是否會返回賦值? – Ezequiel 2014-10-19 21:55:42
我有一點n00b,請你詳細說明爲什麼這可能是一個問題。 – mattihase 2014-10-20 07:11:49