Android 在AndEngine中绘制部分纹理
所以我使用ligbdx已经有一段时间了,做这样的事情非常简单。因此,我想要实现的是,当我有一个大的纹理时,我希望通过给定x,y(开始切割的位置)和宽度,高度(切割部分的大小)来获得该纹理的一部分,然后将该部分用作精灵或任何可以在安丁尼场景中绘制的东西 在libgdx中,它是这样的:Android 在AndEngine中绘制部分纹理,android,andengine,sprite,Android,Andengine,Sprite,所以我使用ligbdx已经有一段时间了,做这样的事情非常简单。因此,我想要实现的是,当我有一个大的纹理时,我希望通过给定x,y(开始切割的位置)和宽度,高度(切割部分的大小)来获得该纹理的一部分,然后将该部分用作精灵或任何可以在安丁尼场景中绘制的东西 在libgdx中,它是这样的: //loads file from assets into texture Texture texture = new Texture(Gdx.files.internal("data/texture5.png"))
//loads file from assets into texture
Texture texture = new Texture(Gdx.files.internal("data/texture5.png"));
//cuts a part of it into drawable element
TextureRegion part = new TexureRegion(texture, x, y, width, height);
部分就是我需要在屏幕上绘制的纹理部分。在andengine中真的很难做到,以至于现在我在互联网上找不到任何答案,搜索了2个小时 我刚搜索了几个小时,什么也没找到。但我不小心尝试了这个,它成功了。这是个老问题,但不管怎样。也许这会有帮助
ITexture texture = null;
try {
texture = new BitmapTexture(engine.getTextureManager(),
new IInputStreamOpener() {
public InputStream open() throws IOException {
return engine.getAssets().open(path);
}
});
texture.load();
} catch (IOException e) {
e.printStackTrace();
}
ITextureRegion texturePart = new TextureRegion(texture, x, y, width, height);