Sunday, 15 May 2011

java - Android bitmap sometimes returning null -


I am making a brick-breaker game for Android and am trying to change the background image. In the first part of the game, it works 100% of the time.

  mBackgroundImage = BitmapFactory.decodeResource (gameView.getContext (). GetResources (), RDRA.  

Planet 3 is in race / Dryable folder.

If I come back to the previous screen and start a new game, then I get around 90% of the NPE time. If I use a resource that I want to use as a folder like "Planet 3" I'm working in strangely, it works 100%, even if it is a new game or the first game.

Why is it a while I do not and others do not. I usually find that when this works, because I'm debugging it and moving through line line, though this can only be coincidental. / P>

At this time I have the code, TheGame is the current thread on which the game is running, the code described above is in the creator of this, I. E. Every time a new game is created, set the background You should be the same as the "planet3". To verify the file "background" in fear, you can see the file structure on the left: Enter the image details here

As far as the error is concerned, I do not have a real error message because it just says that the MOOC has stopped working, and then restarts the program.

Better resolution


No comments:

Post a Comment