在Andengine中将图像作为Sprite加载

时间:2012-08-10 05:35:01

标签: android sprite andengine

我搜索了所有论坛,但我无法获得任何正常工作的代码。 我想从SD卡和引擎加载图像作为精灵。 任何人都可以为我提供代码吗?我正在使用

    File imageFile = new File("/path/to/image");
    BitmapTextureAtlas texture = new BitmapTextureAtlas(width , height , TextureOptions.DEFAULT);
    ITextureSource fileTextureSource = new FileTextureSource(imageFile);
    TextureRegion textureRegion = TextureRegionFactory.createFromSource(texture,fileTextureSource ,0,0);

但是

ITextureSource fileTextureSource = new FileTextureSource(imageFile);

给我一​​个错误,即ITextureSource无法解析为某种类型。 我正在使用AndEngine GLES1。请帮帮我,给我一个从SD卡制作精灵的方法。

1 个答案:

答案 0 :(得分:6)

我没有尝试过代码,但我把它放在Eclipse中并尝试修复它以便编译。这是结果:

File imageFile = new File("/path/to/image");
BitmapTextureAtlas texture = new BitmapTextureAtlas(width , height , TextureOptions.DEFAULT);
FileBitmapTextureAtlasSource fileTextureSource = new FileBitmapTextureAtlasSource(imageFile);
TextureRegion textureRegion = TextureRegionFactory.createFromSource(texture,fileTextureSource ,0,0, true);
相关问题