在Android Studio中将AndEngine的图像放在何处

问题描述 投票:1回答:1

它通常在drawable文件夹中,但当我把它们放在那里时,我得到了一个FileNotFoundException。不应该AssetBasePath"drawable/"然后纹理区域"ire.png",对吗?如果我忘记提及其他任何事情,请介意我。

android andengine
1个回答
1
投票

在项目模块中,在src - > res文件夹中找到drawable。

如果你没有得到drawable文件夹创建一个并保留你的资源。

@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在drawable文件夹中。


您还可以将资源放在assets文件夹中并以这种方式获取:

@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位于gfx文件夹中,存在于assets文件夹中。

© www.soinside.com 2019 - 2024. All rights reserved.