загрузка SVG в AndEngine - PullRequest
       4

загрузка SVG в AndEngine

2 голосов
/ 30 декабря 2011

Кто-нибудь знаком с AndEngine и загрузкой SVG?

Сейчас я пытаюсь загрузить фон для сцены, и по какой-то причине он вообще не появляется ..

Вот код, который я использую, чтобы загрузить SVG и прикрепить его к сцене.

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

Ответы [ 2 ]

6 голосов
/ 30 декабря 2011

Включаете ли вы следующие операторы в свой код в loadResources:

    try {
        this.mBuildableTexture.build(new BlackPawnTextureBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1));
    } catch (final TextureAtlasSourcePackingException e) {
        Debug.e(e);
    }

    this.mEngine.getTextureManager().loadTexture(this.mBuildableTexture);
5 голосов
/ 30 декабря 2011

На мой взгляд, наименование класса BlackPawnTextureAtlasBuilder довольно интуитивно понятно, поскольку:

  1. Это реализация интерфейса ITextureAtlasBuilder
  2. Класс javadoc говорит:

: -)

...