Where to put images for AndEngine in Android Studio

150 Views Asked by At

It's normally in the drawable folder but when I put them there, I get a FileNotFoundException. Shouldn't the AssetBasePath be like "drawable/" and then texture region "ire.png", right? Please mind me if I forgot to mention anything else.

1

There are 1 best solutions below

10
AAryan On BEST ANSWER

Inside your project module, find drawable in src -> res folder.

If you're not getting drawable folder create one and keep your resource there.

@Override
protected void onCreateResources() {

    BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(getTextureManager(), 71, 71, TextureOptions.DEFAULT);
    mBitmapTextureAtlas.load();
    TextureRegion mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "ic_launcher.png", 0, 0);
}

ic_launcher.png is in drawable folder.


Also you can put your resources in assets folder and get in this way :

@Override
protected void onCreateResources() {

   ITexture backgroundTexture=new BitmapTexture(getTextureManager(), new IInputStreamOpener() {
            @Override
            public InputStream open() throws IOException {
                return getAssets().open("gfx/background.png");
            }
        });
}

background.png is in gfx folder that exist in assets folder.