In Android Studio, I'm trying to create a sprite with AndEngine, but it failed to display the sprite, it only shows a black screen. I'v searched and tried different methods for hours.
Here is the structure:
-myApplication
-andEngine
-app
-res
-drawable
-stand.png
Here is the codes:
@Override
public void onCreateResources() {
this.mBitmapTextureAtlas = new BitmapTextureAtlas(getTextureManager(), 30, 30, TextureOptions.DEFAULT);
mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);
mBitmapTextureAtlas.load();
}
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mMainScene = new Scene();
this.mMainScene.setBackground(new Background(1, 1, 1));
final Sprite oPlayer = new Sprite(100, 100, mPlayerTextureRegion, getVertexBufferObjectManager());
this.mMainScene.attachChild(oPlayer);
return this.mMainScene;
}
Any help will be appreciated
Thanks.
Check your logcat it's may be an exception.
As I check your code, this line may be reason of exception.
Check dimension of your
stand.pngit should not greater than30*30otherwise pass greater value, when you're creating object ofBitmapTextureAtlas.