android - AndEngine AnimatedSprite 不显示

标签 android andengine

我刚开始使用动画 Sprite 并添加了一个,但它似乎不起作用,我们将不胜感激。

它只是将 sprite 显示为一个黑框。但是背景显示出来了。我发现如果我不使用 (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)

我的类(class)

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

}

最佳答案

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

关于android - AndEngine AnimatedSprite 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14190521/

相关文章:

android - 动画 Sprite 动画在 AndEngine 中不止一次

java - 使用 AndEngine 限制声音播放

android - java.lang.UnsatisfiedLinkError : Couldn't load andenginephysicsbox2dextension from loader dalvik. system.PathClassLoader ... findLibrary 返回空

java - 单元测试android : How to return function not to be null when calls another function return and use

java - 如何在启动其他 Activity 后再次停止已经运行的媒体播放器并通过按钮启动该 Activity ?

android - 使用 Eclipse 3.6 和 Android SDK 有什么问题吗?

安卓 ORMLite。左加入。 WHERE 子句

java - 将 ListView 添加到 pageindicator fragment

java - 机构未创建正确的引擎

java - `AndEngine` 示例未通过更新到最新的 anddorid SDK 和 ADT 在 Eclipse 上运行