我正在尝试将一些 SVG 加载到我的游戏中,但我遇到了麻烦。我曾尝试阅读论坛上的 Android 烹饪书、文档和答案,但找不到解决方案。我现在处于可以实际加载图像并构建游戏的状态,但现在我无法显示它们。见如下:
加载 .svg 图像:
BuildableBitmapTextureAtlas bitmapTextureAtlas = new BuildableBitmapTextureAtlas(
engine.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR); //setting up texture atlas
try {
this.mBuildableBitmapTextureAtlas
.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(
0, 0, 1));
} catch (final TextureAtlasBuilderException e) {
Debug.e(e);
}
SVGBitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/game/");
mLowResTextureRegion = SVGBitmapTextureAtlasTextureRegionFactory
.createFromAsset(bitmapTextureAtlas, activity,
"spinningarrow.svg", 32, 32);
mMedResTextureRegion = SVGBitmapTextureAtlasTextureRegionFactory
.createFromAsset(bitmapTextureAtlas, activity, "spinningarrow.svg",
128, 128);
// Create a high-res (256x256) texture region of svg_image.svg
mHiResTextureRegion = SVGBitmapTextureAtlasTextureRegionFactory
.createFromAsset(bitmapTextureAtlas, activity, "spinningarrow.svg",
256, 256);
bitmapTextureAtlas.load();
实际上将其附加到场景中:
float currentSpritePosition = (WIDTH / ((SPRITE_SIZE) * SPRITE_COUNT)) + SPRITE_SIZE * 0.5f;
Sprite lowResSprite = new Sprite(currentSpritePosition, HEIGHT / 2, SPRITE_SIZE, SPRITE_SIZE, rM.mLowResTextureRegion, rM.engine.getVertexBufferObjectManager());
attachChild(lowResSprite);
currentSpritePosition += SPRITE_SIZE;
// Create & attach the med-res sprite to the scene (mid)
Sprite medResSprite = new Sprite(currentSpritePosition, HEIGHT / 2, SPRITE_SIZE, SPRITE_SIZE, rM.mMedResTextureRegion, rM.engine.getVertexBufferObjectManager());
attachChild(medResSprite);
currentSpritePosition += SPRITE_SIZE;
// Create & attach the high-res sprite to the scene (right side)
Sprite hiResSprite = new Sprite(currentSpritePosition, HEIGHT / 2, SPRITE_SIZE, SPRITE_SIZE, rM.mHiResTextureRegion, rM.engine.getVertexBufferObjectManager());
attachChild(hiResSprite);
这建立了,但我看不到图像;即使我硬编码它的坐标。
有问题的 svg 位于http://www.sendspace.com/file/nnjsfe