java - 在 AndEngine 中加载 SVG

标签 java android andengine

有人熟悉 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);
             }

最佳答案

您是否在 loadResources 的代码中包含以下语句:

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

    this.mEngine.getTextureManager().loadTexture(this.mBuildableTexture);

关于java - 在 AndEngine 中加载 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8680842/

相关文章:

java - 在 Android 中通过手指拖动控制 XY 移动

java - Android 测试类

java - Google Sheet API V4 Java,从列号获取列字母

java - 在 Java 中生成泊松到达

android - 处理问题 "javax/xml/parsers/DocumentBuilder.class": Ill-advised or mistaken usage of a core class (java. * 或 javax.*)

java - OpenGL 模板(剪辑实体)

java - 在那种情况下我真的需要实现迭代器吗?

android - 如何将 💙 或任何其他表情符号放入 XML 字符串中?

android - 如何让 Android 设备在 root 设备上进入休眠模式(比如,点击按钮)

java - 软键盘监听器