2011-12-30 79 views
2

是否有人熟悉AndEngine并加载svg的?在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); 
      } 

回答

6

你包括你的代码下面的语句在loadResources:

​​
+0

我注意到,在AndEngine示例中。不知道这是否是它没有工作的原因,但我决定不将它包含在我的代码中,因为我认为它不是必需的。也许这就是为什么它不工作?! – 2011-12-30 15:27:49

+0

即使我真的不知道这个功能是干什么的......但是肯定有必要运行......我们可以得出结论,也许它会根据名字建议构建纹理......) – 2011-12-30 15:43:15

+0

也许是soo ...它的名字奇怪“BlackPawn”哈哈idk,我会尝试当我回家和接受答案,并让你知道它是否工作。谢谢! – 2011-12-30 15:47:13

5

海事组织BlackPawnTextureAtlasBuilder类的命名是非常直观的,如:

  1. 这是一个实现ITextureAtlasBuilder接口
  2. javadoc类说:

:-)

+1

嘿尼古拉斯! Dude你是一个惊人的编码器!感谢您的引擎,我正在构建一个非常棒的游戏。是的,我只是注意到了文档。这很酷你如何做到这一点。非常感谢你。我们都欠你的! – 2011-12-30 18:44:41