3

我刚开始使用动画精灵并添加了一个,但它似乎不起作用,任何帮助将不胜感激。

它只是将精灵显示为一个黑盒子。但背景会显示出来。我发现如果我不使用(bi~).load();它会显示为一个黑盒子,但它有一个load();.

原木猫

01-07 10:47:48.049: W/System.err(2879): org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder$TextureAtlasBuilderException: Could not build: 'AssetBitmapTextureAtlasSource(gfx/face_hexagon_tiled.png)' into: 'BitmapTextureAtlas'.
01-07 10:47:48.049: W/System.err(2879):     at org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder.build(BlackPawnTextureAtlasBuilder.java:87)
01-07 10:47:48.049: W/System.err(2879):     at org.andengine.opengl.texture.atlas.buildable.BuildableTextureAtlas.build(BuildableTextureAtlas.java:236)
01-07 10:47:48.059: W/System.err(2879):     at com.example.pilet.Game.onCreateResources(Game.java:48)
01-07 10:47:48.059: W/System.err(2879):     at org.andengine.ui.activity.BaseGameActivity.onCreateGame(BaseGameActivity.java:181)
01-07 10:47:48.059: W/System.err(2879):     at org.andengine.ui.activity.BaseGameActivity.onSurfaceCreated(BaseGameActivity.java:110)
01-07 10:47:48.059: W/System.err(2879):     at org.andengine.opengl.view.EngineRenderer.onSurfaceCreated(EngineRenderer.java:80)
01-07 10:47:48.059: W/System.err(2879):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
01-07 10:47:48.059: W/System.err(2879):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

我的课

private Camera mCamera;
private int c_width = 640;
private int c_height = 480;
private BuildableBitmapTextureAtlas mBitmapTextureAtlas;
private TiledTextureRegion pi;
private Scene mScene;

@Override
public EngineOptions onCreateEngineOptions() {
    mCamera = new Camera(0, 0, c_width, c_height);
    EngineOptions options = new EngineOptions(true,
            ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
                    c_width, c_height), mCamera);
    return options;
}

@Override
public void onCreateResources(
        OnCreateResourcesCallback pOnCreateResourcesCallback)
        throws Exception {
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    this.mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(
            this.getTextureManager(), 32, 32, TextureOptions.NEAREST);
    this.pi = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
            this.mBitmapTextureAtlas, this, "face_box_tiled.png", 2, 1);
    try {
        this.mBitmapTextureAtlas
                .build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(
                        0, 0, 1));
        this.mBitmapTextureAtlas.load();
    } catch (Exception e) {
        Debug.e(e);
    }

    pOnCreateResourcesCallback.onCreateResourcesFinished();
}

@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
        throws Exception {
    this.mScene = new Scene();
    this.mScene.setBackground(new Background(0.82f, 0.91f, 0.7121f));
    pOnCreateSceneCallback.onCreateSceneFinished(this.mScene);
}

@Override
public void onPopulateScene(Scene pScene,
        OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
    final AnimatedSprite piA = new AnimatedSprite(32, 32, pi,
            this.getVertexBufferObjectManager());
    piA.animate(100);
    this.mScene.attachChild(piA);

    pOnPopulateSceneCallback.onPopulateSceneFinished();
}

}
4

1 回答 1

11

看起来图集上没有足够的空间用于您的精灵纹理。尝试增加您的地图集大小,使其大于或等于您的精灵大小+填充。

于 2013-01-31T10:51:06.793 回答