У меня есть приложение OpenGL, где я заполняю двумерный список int данными, я также записываю размер каждый раз, когда помещаю в него данные. Работает решетка, есть 236 ряд. Но после того, как я вызываю метод позже в журнале, он возвращает мне, что размер равен 0.
Вот как выглядит структура:
Main.java
...
onDrawFrame(GL10 gl) {
if (first == true) {
// the data comes from another method
myList.setData(x, y); // I send the the data for the List
// and also log the List size, which at the end is 236
first = false;
}
myList.check(); // It just Logs the List size, which gives back 0
}
...
List.java
private List<int[]> dataS = new ArrayList<int[]>();
public void setData(int x, int y) {
dataS.add(new int[] { x, y });
Log.i("size", "size: " + dataS.size());
}
public void check() {
Log.i("check", "check: " + dataS.size());
}
Я просто не могу понять, в чем проблема, надеюсь, кто-нибудь может мне помочь.
Весь код:
Main.java
public class Main extends GLSurfaceView implements Renderer {
public void drawGame(GL10 gl) {
if (firstGameFrame == true) {
tMap.setMap();
firstGameFrame = false;
}
collision.check();
}
}
Map.java
public class Map {
public void setMap() {
// map1 is an int map1[][] = {{1,0,1}, {1,1,1}, {0,0,1}}; - of course there are more data in it
for (int z = 0; z < map1.length; z++) {
for (int x = 0; x < map1[z].length; x++) {
if (map1[z][x] == 1) {
collision.getWall((x*2) - 23, (z * 2) - 27);
}
}
}
}
}
Collision.java
public class Collision {
private List<Integer[]> wallCoord = new ArrayList<Integer[]>();
public void getWall(int x, int y) {
wallCoord.add(new Integer[] { x, y });
Log.i("getwall", "getwall " + x + " " + y + " size " + wallCoord.size());
}
public void check() {
Log.i("coords", "size: " + wallCoord.size());
}
}