Andengine动态壁纸:低端设备上的纹理松动

时间:2013-06-23 09:38:07

标签: andengine live-wallpaper

我正在使用Andengine GLES2 Anchor中心分支开发动态壁纸,基于Development Cookbook.Wallpaper在中高端设备上运行良好,但在低端设备上显示出问题。我在三星Galaxy ace,Micromax上进行了测试Funbook平板电脑和问题发生器三星Galaxy Y.问题只发现在三星Galaxy Y上我唯一的低端设备。

问题

当有时解锁屏幕时,或者当有时返回主页时,我失去了所有精灵的纹理,错误不是以可预测的方式生成的,有时它根本不会导致任何问题,但是当它发生时我的工作甚至在我的预览模式下我必须强制关闭应用程序并再次启动应用程序。

这些是我的动态壁纸的细节, 壁纸有一个背景精灵,一个主图像精灵,两个带有一些初始化器和修饰符的BatchedSpriteParticleSystem 我在资产中有一个sepretae文件夹用于低端设备(320 * 480),我保留小图像并将所有图像加载到单个纹理图集中,在这种情况下,其他方面我使用两个纹理图集一个用于背景图像,一个用于我的主图像和两个粒子图像。我正在使用资源管理器calss根据andengine cookbook加载纹理

请帮我解决这个问题,我不知道我在哪里出错了 这是我的代码......

下面给出的LiveWallpaperExtensionService

LiveWallpaperExtensionService

@TargetApi(13)
public class LiveWallpaperExtensionService extends BaseLiveWallpaperService {

    public Sprite bg_Sprite;
    public Sprite main_image_sprite;
    public SpriteBackground background;

    public BatchedSpriteParticleSystem beamParticleSystem;
    public BatchedSpriteParticleSystem starParticleSystem;

    private Camera mCamera;
    private Scene mScene;


    @Override
    public org.andengine.engine.Engine onCreateEngine(
            final EngineOptions pEngineOptions) {
        return new FixedStepEngine(pEngineOptions, 50);
    }

    public EngineOptions onCreateEngineOptions() {

        Display display = ((WindowManager) getSystemService(WINDOW_SERVICE))
                .getDefaultDisplay();
        Utils.setGlobalWidthandHeight(Utils.getDisplaySize(display));

        mCamera = new Camera(0, 0, Global.Width, Global.Height);

        EngineOptions engineOptions = new EngineOptions(true,
                ScreenOrientation.PORTRAIT_SENSOR, new FillResolutionPolicy(),
                mCamera);

        engineOptions.getRenderOptions().setDithering(true);
        return engineOptions;
    }


    public void onCreateResources(
            OnCreateResourcesCallback pOnCreateResourcesCallback) {

        System.out.println("On create resourses");
        ResourceManager.getInstance().loadBlueTextures(mEngine, this);
        pOnCreateResourcesCallback.onCreateResourcesFinished();

    }

    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) {
        System.out.println("On create scene");
        mScene = new Scene();
        pOnCreateSceneCallback.onCreateSceneFinished(mScene);
    }

    public void onPopulateScene(Scene arg0,
            OnPopulateSceneCallback pOnPopulateSceneCallback) {

        System.out.println("on populate ");

        final float positionX = Global.Width * 0.5f;
        final float positionY = Global.Height * 0.5f;


        bg_Sprite = new Sprite(positionX, positionY,
                ResourceManager.getInstance().mBackgroundTextureRegion,
                this.getVertexBufferObjectManager());

        main_image_sprite = new Sprite(positionX, positionY,
                ResourceManager.getInstance().mJesusTextureRegion,
                this.getVertexBufferObjectManager());

        /*
         * Define the center point of the particle system spawn location
         */
        final int bparticleSpawnCenterX = (int) (Global.Width * 0.5f);
        final int bparticleSpawnCenterY = (int) ((Global.Height * 0.5f) + ((Global.Height * 0.5f)) * 0.5f) - 25;
        /* Define the radius of the circle for the particle emitter */
        final float particleEmitterRadius = 50;
        /* Create the particle emitter */
        CircleOutlineParticleEmitter bparticleEmitter = new CircleOutlineParticleEmitter(
                bparticleSpawnCenterX, bparticleSpawnCenterY,
                particleEmitterRadius);

        beamParticleSystem = new BatchedSpriteParticleSystem(bparticleEmitter,
                10, 15, 50, ResourceManager.getInstance().mBeamTextureRegion,
                mEngine.getVertexBufferObjectManager());

        beamParticleSystem
                .addParticleInitializer(new ExpireParticleInitializer<UncoloredSprite>(
                        3));

        beamParticleSystem
                .addParticleInitializer(new AccelerationParticleInitializer<UncoloredSprite>(
                        -150, 150, -150, 150));

        RectangleParticleEmitter particleEmitter = new RectangleParticleEmitter(
                ((int) (Global.Width * 0.5f)), ((int) (Global.Height * 0.5f)),
                Global.Width, Global.Height);

        // Create a batched particle system for efficiency
        starParticleSystem = new BatchedSpriteParticleSystem(particleEmitter,
                1, 2, 20, ResourceManager.getInstance().mStarTextureRegion,
                mEngine.getVertexBufferObjectManager());

        /* Add an acceleration initializer to the particle system */

        starParticleSystem
                .addParticleInitializer(new ExpireParticleInitializer<UncoloredSprite>(
                        10));

        starParticleSystem
                .addParticleInitializer(new RotationParticleInitializer<UncoloredSprite>(
                        0, 160));

        /* Define min/max values for the particle's scale */

        starParticleSystem
                .addParticleInitializer(new ScaleParticleInitializer<UncoloredSprite>(
                        0.3f, 1.5f));

        /* Define the alpha modifier's properties */

        starParticleSystem
                .addParticleModifier(new AlphaParticleModifier<UncoloredSprite>(
                        0, 2, 0, 1));

        /* Define the rotation modifier's properties */

        starParticleSystem
                .addParticleModifier(new RotationParticleModifier<UncoloredSprite>(
                        1, 9, 0, 180));

        // Add alpha ('fade out') modifier
        starParticleSystem
                .addParticleModifier(new AlphaParticleModifier<UncoloredSprite>(
                        8, 10, 1, 0));




        /*
         * Create the SpriteBackground object, specifying the color values &
         * Sprite object to display
         */

        final float red = 0.7f;
        final float green = 0.78f;
        final float blue = 0.85f;
        final float alpha = 1;

        background = new SpriteBackground(red, green, blue, bg_Sprite);
        mScene.setBackground(background);
        mScene.setBackgroundEnabled(true);

        // Attach our particle system to the scene
        mScene.attachChild(starParticleSystem);
        mScene.attachChild(beamParticleSystem);

        mScene.attachChild(main_image_sprite);

        bg_Sprite.setIgnoreUpdate(true);
        main_image_sprite.setIgnoreUpdate(true);

        pOnPopulateSceneCallback.onPopulateSceneFinished();
    }

    @Override
    protected synchronized void onPause() {
        System.out.println("On paused");
        super.onPause();

        if (starParticleSystem != null) {
            starParticleSystem.setParticlesSpawnEnabled(false);
        }
        if (beamParticleSystem != null) {
            beamParticleSystem.setParticlesSpawnEnabled(false);
        }

    }

    @Override
    protected synchronized void onResume() {

        System.out.println("On resume");
        super.onResume();

        if (starParticleSystem != null) {
            starParticleSystem.setParticlesSpawnEnabled(true);
        }
        if (beamParticleSystem != null) {
            beamParticleSystem.setParticlesSpawnEnabled(true);
        }

    }


    }



}

请帮我解决这个问题,我欢迎所有的想法建议,有任何想法,你解决这个问题....

1 个答案:

答案 0 :(得分:2)

我注意到Galaxy Y有很多问题,我的游戏收到很多崩溃报告,直到我阻止它们下载它并且所有报告都停止了[它是唯一有问题的设备]

我建议你做同样的事情

编辑: 如果您想选择支持哪些设备,可以使用此示例

<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:anyDensity="true" />

根据需要修改