Question

Getting NullPointerException when try to load files for Particle Effect.

particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("hdpi/particles/progressbar"), Gdx.files.internal("hdpi/particles"));

And here is stack trace:

Exception in thread "Timer-0" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1372)
at com.badlogic.gdx.backends.lwjgl.LwjglGL10.glGenTextures(LwjglGL10.java:240)
at com.badlogic.gdx.graphics.Texture.createGLHandle(Texture.java:166)
at com.badlogic.gdx.graphics.Texture.create(Texture.java:158)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:126)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadTexture(ParticleEffect.java:198)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadEmitterImages(ParticleEffect.java:193)
at com.badlogic.gdx.graphics.g2d.ParticleEffect.load(ParticleEffect.java:141)
at com.yyy.xxx.Screens.GameScreen.<init>(GameScreen.java:38)
at com.yyy.xxx.MyScreen$3.getScreenInstance(MyScreen.java:27)
at com.yyy.xxx.ScreenManager.show(ScreenManager.java:33)
at com.yyy.xxx.ScreenChangeTask.run(ScreenChangeTask.java:15)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)

Any suggestions why?

UPDATE:

I tryed to run on android and it works, BUT I get something like this:
enter image description here

but if I turn off phone screen and turn on it back, than I see this, how it should be:
enter image description here

I think this Update will reply on first comment.

1) issue with desktop is not resolved 2) new issue with bad particles images on app start...

Was it helpful?

Solution

I had this code

particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.
                    internal("hdpi/particles/progressbar.p"), 
                    Gdx.files.internal("hdpi/particles/"));

in constructor of public class GameScreen implements Screen. I moved this code into that place, where all assets are loaded ONCE in my app. This resolved both issues. Now it is working on Desktop, and there is no problems with bad rendering of particles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top