android - 自动视差安德引擎 : black screen

标签 android andengine

自动视差 AndEngine给出黑屏。

public class MainActivity extends SimpleBaseGameActivity {
    static final int CAMERA_WIDTH = 480;
    static final int CAMERA_HEIGHT = 320;
    int k = 700;
    public Font mFont;
    public Camera mCamera;

    // A reference to the current scene
    public Scene mCurrentScene;

    public BitmapTextureAtlas mAutoParallaxBackgroundTexture;
    public TextureRegion mParallaxLayer;

    public static MainActivity instance;

    public static MainActivity getSharedInstance() {
        return instance;
    }

    @Override
    public EngineOptions onCreateEngineOptions() {
        instance = this;
        mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

        return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT),
                mCamera);
    }

    @Override
    protected void onCreateResources() {
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

        mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1024, TextureOptions.DEFAULT);

        mParallaxLayer = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this,
                "background.png", 0, 0);
    }

    @Override
    protected Scene onCreateScene() {
        mEngine.registerUpdateHandler(new FPSLogger());

        mCurrentScene = new Scene();

        final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 10);
        autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(5.0f, new Sprite(0, mCamera.getHeight()
                - this.mParallaxLayer.getHeight(), this.mParallaxLayer, this.getVertexBufferObjectManager())));
        mCurrentScene.setBackground(autoParallaxBackground);

        return mCurrentScene;
    }
}

最佳答案

看起来您没有“加载”TextureAtlas。在 onCreateResources() block 的末尾添加:

mAutoParallaxBackgroundTexture.load();

关于android - 自动视差安德引擎 : black screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12611010/

相关文章:

javascript - 如何从在线流媒体电台获取流媒体网址

java - 在android上拖放一个按钮..帮助

android - 媒体文件中的 DTD 问题

android - 编译和引擎项目时出错

android - 如何防止 Prismatic Joint 重置为初始交易限额?

java - Andengine 游戏在尝试显示获胜者的 Facebook 个人资料图片时出现空指针异常

android - 从 Fragment 到 Activity 的数据通信不起作用

java - 为什么我必须包含一个 Thread.sleep(10) 来获取要通过套接字发送的数据

java - 如何以编程方式退出 Android 应用程序?

android - 和引擎一起 toast 提问?