0

I'm using libgdx trying to make a game, but when I run this from the desktoplauncher, I get a error in the console:

Exception in thread "LWJGL Application" java.lang.NullPointerException
    at com.orhantozan.game.PongMain.render(PongMain.java:216)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:215)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)

What is the cause of this? I dont know what the error means :(

Core: http://pastebin.com/r74wB5xX

Desktop: http://pastebin.com/i0w4H4Wq

Dew class: http://pastebin.com/wuPnUBbg

Nahro
  • 406
  • 3
  • 12

1 Answers1

0

Make sure the dewList field gets initialized. Alternatively change

Array<Dew> dewList;

to

Array<Dew> dewList = new Array();

if possible.

defectus
  • 1,947
  • 2
  • 16
  • 21
  • That helped :) Thank you. But ppl also said that you should declare a object at the start of a class, and create an instance in the create() method. So what is the difference between yours and and creating the instance in the create() method – Nahro Jun 02 '15 at 19:03
  • I've got no idea who says that (init object in the create method) but nowhere in your `create` you initialize that field (`dewList`). – defectus Jun 02 '15 at 19:07
  • Actually I posted this on reddit too and some guy just said Array dewlist; should be in the start and dewlist = new Array(); should be in create() – Nahro Jun 02 '15 at 19:10