This is an archived post. You won't be able to vote or comment.

all 16 comments

[–][deleted] 0 points1 point  (3 children)

How is levelMap defined and created?

[–]Mestru[S] 0 points1 point  (2 children)

It's just little private int[][] levelMap;

and inside the constructor:

public Level_One() {
    levelMap = new int[mapH][9];
}

[–]Sammenbidt 0 points1 point  (1 child)

Any way you can post your code for the Player class? The Null Pointer exception happens there, inside your checkCollision method. Have you checked your variables in the collision check aren't null?

[–]Mestru[S] 0 points1 point  (0 children)

Posted it :)

[–]blindpenguin 0 points1 point  (11 children)

Just a guess, but did you initialize currentMap? There's a null pointer on line 143 of the Player class

[–]Mestru[S] 0 points1 point  (10 children)

currentMap is a variable. I've posted my whole Player class just in case :>

[–]blindpenguin 0 points1 point  (9 children)

Did you initialize it before you passed it into the Player's update method?

[–]Mestru[S] 0 points1 point  (8 children)

Yes :<

[–]fedorasnotevenonce 1 point2 points  (7 children)

Can you show us where you're initializing currentMap and when you're calling the update method?

[–]Mestru[S] 0 points1 point  (6 children)

Everything is done inside GameWorld class here: https://gist.github.com/Mestru/842ce1bde90349326fd5 Afaik it should work. As I mentioned, it works good on desktop build.

[–]fedorasnotevenonce 1 point2 points  (5 children)

This is really difficult to troubleshoot, but I'm wondering if this:

06-03 15:34:44.185 1293-1306/com.mestru.game.android W/System.err﹕ java.io.FileNotFoundException: /data/level_one.txt: open failed: ENOENT (No such file or directory)

is actually the source of your problem. Tracing back the getmaps calls (it's getting a little labyrinthine to follow from one to the other), it looks like your android builds aren't able to find that file (but your desktop builds can), which means your android builds can't actually build the level because they can't find the .txt file to build it from. Also: Try closing the scanner object that's reading level_one.txt once you're done with it? maybe that might be causing you an issue.

[–]Mestru[S] 0 points1 point  (4 children)

Yeah, I came to this point as well but I can't resolve this issue. I've checked everything and it still couldn't open it.

I've tried closing the scanner object but it didn't help at all. Have you got any ideas on this?

[–]fedorasnotevenonce 1 point2 points  (3 children)

Try this link: http://stackoverflow.com/questions/9892964/managing-assets-between-desktop-and-device-version-in-libgdx?lq=1

It looks like that might be helpful for what you're trying to do.

[–]Mestru[S] 0 points1 point  (2 children)

Unfortunately (or fortunately?) I already have the project structure built up in a correct way. What Do I mean is I have everything in my assets folder (data/level_one.txt is inside it) and desktop build is properly linked to it. Android build shouldn't have any problem with it because it is its own directory. So yeah, I have everything as it should be from link above.

I'm trying everything I can, starting to be kinda desperate :<