我有一個類Tile來處理對象的位置。編譯器對該類沒有任何問題。MovableObject java語法錯誤
但是,當我嘗試在MovableObject中使用該類時,我無法在創建新Tile時使用這些方法。
這裏是我的代碼:
package game;
public class Tile {
int posx;
int posy;
int indice;
Tile [] proximasSalidas;
//int fila;
//int columna;
public boolean esInterseccion;
boolean esPasillo;
boolean esL;
Tile [] adyacencias;
public Tile(){
posx = 0;
posy = 0;
proximasSalidas = null;
esInterseccion = false;
esPasillo = false;
esL = false;
adyacencias = null;
}
public Tile(int posx,int posy,Tile [] adyacencias,Tile [] proximasSalidas,boolean esPasillo, boolean esInterseccion, boolean esL){
this.posx = posx;
this.posy = posy;
this.proximasSalidas = proximasSalidas;
this.adyacencias = adyacencias;
this.esInterseccion = esInterseccion;
this.esPasillo = esPasillo;
this.esL = esL;
}
public void setValores(int posx,int posy,Tile [] adyacencias,Tile [] proximasSalidas,boolean esPasillo, boolean esInterseccion, boolean esL){
this.posx = posx;
this.posy = posy;
this.proximasSalidas = proximasSalidas;
this.adyacencias = adyacencias;
this.esInterseccion = esInterseccion;
this.esPasillo = esPasillo;
this.esL = esL;
}
}
而且我MovableObject類:
package game;
import java.awt.Graphics2D;
import com.golden.gamedev.*;
import com.golden.gamedev.*;
import com.golden.gamedev.engine.*;
import com.golden.gamedev.object.*;
import com.golden.gamedev.object.sprite.*;
import com.golden.gamedev.engine.BaseAudioRenderer;
public class MovableObject {
public int columna;
public int fila;
public int pos_x;
public int pos_y;
private int moveSize;
public int direction;
public int[] availableDirections;
public int targetTile;
Tile t1 = new Tile(1,1,null,null,false,false,false);//no es pasillo
Tile t0 = new Tile(1,1,null,null,true,false,false);//es pasillo
//adyacencias,proximasSalidas,es pasillo,es interseccion,esL
Tile t3 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t4 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t6 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t7 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t10 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t11 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t13 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t14 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t16 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t17 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t18 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t19 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t20 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t21 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t23 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t25 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t27 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t29 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t31 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t33 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t34 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t35 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t36 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t38 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t41 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t43 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t44 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t46 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t48 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t50 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t52 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t53 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t54 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t55 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t57 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t58 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t60 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t61 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t63 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t64 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t66 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t67 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t68 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t69 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t70 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t71 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t72 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t73 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t74 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t75 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t77 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t78 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t80 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t82 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t83 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t85 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t86 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t88 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t90 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t91 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t93 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t94 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t95 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t96 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t97 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t98 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t100 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t101 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t103 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t104 = new Tile(1,1,null,null,true,false,false);//no es interseccion
Tile t2 = new Tile(1,1,new Tile[]{t3,t16},null,true,true,true);//es L
Tile t8 = new Tile(1,1,new Tile[]{t7,t18},null,true,true,true);//es L
Tile t9 = new Tile(1,1,new Tile[]{t19,t10},null,true,true,true);//es L
Tile t15 = new Tile(1,1,new Tile[]{t14,t21},null,true,true,true);//es L
Tile t37 = new Tile(1,1,new Tile[]{t34,t38},null,true,true,true);//es L
Tile t39 = new Tile(1,1,new Tile[]{t38,t43},null,true,true,true);//es L
Tile t40 = new Tile(1,1,new Tile[]{t44,t41},null,true,true,true);//es L
Tile t42 = new Tile(1,1,new Tile[]{t41,t35},null,true,true,true);//es L
Tile t45 = new Tile(1,1,new Tile[]{t46,t60},null,true,true,true);//es L
Tile t51 = new Tile(1,1,new Tile[]{t50,t61},null,true,true,true);//es L
Tile t99 = new Tile(1,1,new Tile[]{t96,t100},null,true,true,true);//es L
Tile t105 = new Tile(1,1,new Tile[]{t98,t104},null,true,true,true);//es L
Tile t56 = new Tile();
t56.setValores(1,1,new Tile[]{t52,t57,t66},new Tile[]{t5,t59,t76},true,true,false);//es interseccion
...
在上面的代碼,編譯器是不承認setValores()
(在MoveableObject的底部)。
這裏有很多**的代碼。您是否願意分享您收到的例外情況,並將您提供的代碼樣例修改爲絕對的,最低限度的必要條件? – Makoto
很抱歉,但我付出後分享一切會更好。讓我編輯它。 – aldominium
對於從編譯器中得到的確切錯誤,你能更具體嗎? Java編譯器消息通常非常有用。 – Krease