Ich verwende AndEngine GLES2, und ich versuchte, ein Bild auf meinem Handy zu laden, aber was ich bekam, war ein schwarzer BildschirmProbleme beim Laden Bitmap Texturatlas auf dem Bildschirm
Hier sind meine Code unten:
public class BaseActivity extends SimpleBaseGameActivity {
static final int CAMERA_WIDTH = 800;
static final int CAMERA_HEIGHT = 480;
public Font mFont;
public Camera mCamera;
private MainMenuScene mainMenuScene;
public Engine mEngine;
public Scene mScene;
public BuildableBitmapTextureAtlas mBitmapTextureAtlas;
public ITextureRegion mITextureRegion;
@Override
public EngineOptions onCreateEngineOptions() {
instance = this;
mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
}
@Override
protected void onCreateResources() {
mFont = FontFactory.create(this.getFontManager(), this.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32);
mFont.load();
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.BILINEAR);
mITextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "splash1.png");
try {
mBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 1));
} catch (TextureAtlasBuilderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mBitmapTextureAtlas.load();
}
@Override
protected Scene onCreateScene() {
final float positionX = CAMERA_WIDTH * 0.5f;
final float positionY = CAMERA_HEIGHT * 0.5f;
Sprite mSprite = new Sprite(positionX, positionY, mITextureRegion, mEngine.getVertexBufferObjectManager());
mScene.attachChild(mSprite);
return mCurrentScene;
}
Das Logcat zeigt, dass ich eine NullPointerException in meinem OnCreateResources und OnCreateScene habe, und ich habe keine Ahnung, was schief gelaufen ist. Was könnte das Problem sein?