2017-06-20 36 views

回答

1

在您的项目模块中,找到可绘制的src - >res文件夹。

如果你没有得到可绘制的文件夹创建一个,并保持你的资源。

@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在可绘制文件夹中。你


也可以把你的资源资产的文件夹,并得到这样:

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

+0

我知道,但是当我编写路径时,它不起作用。我写的路径是“drawable /” –

+0

@HeshamHaikal你应该在路径app/src/main /中创建创建'assets'文件夹并将资源放入它 – Aryan

+0

非常感谢!顺便说一下,你知道任何最新的视频教程或网站onEngine?因为我发现的所有教程都比较旧 –