well, in my game Im having trouble sending an arraylist of entities over, I think you may need to send them seperately, because the packet size is to big according to kryonet (may work for your code).
inside your packet class you want to make the Player variable / array static
1 2 3 4 5 6 7
| public static ArrayList<Players> players = new ArrayList<Players>();
Player packet = new Player(); packet.players = thePlayerArrayWeAreSending; |
Thank you mister, that worked like a charm!
However, another problem came up. Now when i am trying to loop through it, i'm getting a nullpointer :-(
1 2 3 4 5 6 7 8 9 10 11 12
| java.lang.NullPointerException at NFT.NFTClient.render(NFTClient.java:115) at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:703) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at NFT.NFTClient.main(NFTClient.java:134) Mon Dec 03 10:06:48 CET 2012 ERROR:Game.render() failure - check the game code. org.newdawn.slick.SlickException: Game.render() failure - check the game code. at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:706) at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456) at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361) at NFT.NFTClient.main(NFTClient.java:134) |
Render method:
1 2 3 4 5 6 7 8 9
| public void render(GameContainer gc, Graphics g) throws SlickException { g.drawString("" + System.currentTimeMillis(), 0, 0); for (int i = 0; i < otherplayers.size(); i++) { Player currentPlayer = otherplayers.get(i); g.drawString(currentPlayer.getName(), 10, (i * 10) + 10); } } |
It works fine without to loop, and i can't quite figure out what is wrong with the loop