loading SVG in AndEngine

孤人 提交于 2019-12-07 22:46:49

问题


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);
             }

回答1:


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);



回答2:


Imo the naming of the BlackPawnTextureAtlasBuilder class is pretty intuitive, as:

  1. It is an implementation ITextureAtlasBuilder interface
  2. The class javadoc says:

    • @author Jim Scott (BlackPawn)
    • @since 16:03:01 - 12.08.2010
    • @see http://www.blackpawn.com/texts/lightmaps/default.html

:-)



来源:https://stackoverflow.com/questions/8680842/loading-svg-in-andengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!