在AndEngine装载SVG [英] loading SVG in AndEngine
本文介绍了在AndEngine装载SVG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是任何人都熟悉AndEngine和加载SVG的?
现在我试图加载一个场景中的背景,它不都出现某种原因..
下面是个code我使用加载SVG并将其连接到现场。
//在我onLoadResources方法
this.mBuildableTexture =新BuildableBitmapTexture(1024,1024 TextureOptions.BILINEAR_ preMULTIPLYALPHA);
SVGTextureRegionFactory.setAssetBasePath(GFX /);
this.mSVGTestTextureRegions = SVGTextureRegionFactory.createFromAsset(this.mBuildableTexture,对此,background.svg,16,16);// OnLoadScene方法最后BaseTextureRegion baseTextureRegion = this.mSVGTestTextureRegions;
如果(baseTextureRegion的instanceof TextureRegion){
最后TextureRegion地区=(TextureRegion)baseTextureRegion; 最终浮动的centerX = this.mCamera.getWidth()/ 2;
最终浮动centerY = this.mCamera.getHeight()/ 2; 最终浮动X =的centerX - SIZE * 0.5F;
最终浮动Y = centerY - SIZE * 0.5F; 精灵backgroundSprite =新精灵(X,Y,大小,尺寸,大区);
/ *保护无效onInitDraw(最终GL10 PGL)
{
super.onInitDraw(PGL);
GLHelper.enableTextures(PGL);
GLHelper.enableTexCoordArray(PGL);
GLHelper.enableDither(PGL);
}
}; * / mScene.setBackground(新SpriteBackground(0.0,0.0,0.0,backgroundSprite));
backgroundSprite.setIgnoreUpdate(真);
}
解决方案
您,包括您的code以下语句loadResources:
{尝试
this.mBuildableTexture.build(新BlackPawnTextureBuilder&下; IBitmapTextureAtlasSource,BitmapTextureAtlas>(1));
}赶上(最终TextureAtlasSourcePackingException E){
Debug.e(E);
} 。this.mEngine.getTextureManager()loadTexture(this.mBuildableTexture);
Is anyone familiar with AndEngine and loading svg's?
Right now i am trying to load a background for a scene and it doesnt appear at all for some reason..
Here is th code i am using to load the SVG and attach it to the scene.
//In my onLoadResources method
this.mBuildableTexture = new BuildableBitmapTexture(1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
SVGTextureRegionFactory.setAssetBasePath("gfx/");
this.mSVGTestTextureRegions = SVGTextureRegionFactory.createFromAsset(this.mBuildableTexture, this, "background.svg", 16, 16);
//OnLoadScene method
final BaseTextureRegion baseTextureRegion = this.mSVGTestTextureRegions;
if(baseTextureRegion instanceof TextureRegion) {
final TextureRegion Region = (TextureRegion)baseTextureRegion;
final float centerX = this.mCamera.getWidth() / 2;
final float centerY = this.mCamera.getHeight() / 2;
final float x = centerX - SIZE * 0.5f;
final float y = centerY - SIZE * 0.5f;
Sprite backgroundSprite = new Sprite(x,y,SIZE,SIZE,Region);
/*protected void onInitDraw(final GL10 pGL)
{
super.onInitDraw(pGL);
GLHelper.enableTextures(pGL);
GLHelper.enableTexCoordArray(pGL);
GLHelper.enableDither(pGL);
}
};*/
mScene.setBackground(new SpriteBackground(0.0f,0.0f,0.0f,backgroundSprite));
backgroundSprite.setIgnoreUpdate(true);
}
解决方案
Are you including the following statements in your code in loadResources:
try {
this.mBuildableTexture.build(new BlackPawnTextureBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1));
} catch (final TextureAtlasSourcePackingException e) {
Debug.e(e);
}
this.mEngine.getTextureManager().loadTexture(this.mBuildableTexture);
这篇关于在AndEngine装载SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文