Hi,
I cant seem to get a sound effect running in my game.
I originally didn’t start my game as a libgdx project, but only later in the development process did I add the gdx.jar library file, thinking this way I could use the music & sound class from libgdx.
So I am trying to get sound effect to play in my game, but it’s just not working.
I keep getting nullpointerexceptions.
I’m loading the soudfile in my constructor like this
Sound sound = Gdx.audio.newSound(Gdx.files
.internal("data/powerup.ogg"));
and then tried to play it with this code:
sound.play()
but whatever I change i keep getting a nullpointerexception which i dont understand:
Does it maybe have to do with the fact that I havent started the project with libgdx and so i dont have all these other folders one usually have like [core], , [android] etc??
this is what my exception looks like:
java.lang.NullPointerException
at com.knightmare.KnightmareGame.(KnightmareGame.java:122)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)