AndEngine AnimatedSprite没有显示

时间:2013-01-07 05:40:45

标签: android andengine

我刚刚开始使用动画精灵并添加了一个,但它似乎不起作用,任何帮助都会受到赞赏。

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

Log Cat

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

}

1 个答案:

答案 0 :(得分:11)

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