-2

我在一个带有andengine的android游戏项目中,比如FruitNinja,我用来从下到上扔图像项目工作正常,但有时我使用System.gc()但没有帮助

致命信号 11 (SIGSEGV) 在 0xdeadbaad (code=1)

我的代码是

private void throwHardware(final float pX, final float pY) {

    final FixtureDef boxFixtureDef = PhysicsFactory.createFixtureDef(0.1f,
            0.5f, 0.5f);
    boxFixtureDef.filter.categoryBits = 0x0002;
    boxFixtureDef.filter.maskBits = 0x0004;
    boxFixtureDef.filter.groupIndex = 2;
    Random rng = new Random();
    generated1 = new ArrayList<Integer>();
    r = rng.nextInt(8);
    Log.e(Integer.toString(r), "r");
    if (r == 0) {
        Hardware = new Sprite(pX, pY, java,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, java,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {

                    if (a == 0) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        wrong();
                        question();

                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 1) {
        Hardware = new Sprite(pX, pY, facebook,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);

        mHardware[active] = new Sprite(pX, pY, this.facebook,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 1) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        wrong();
                        question();
                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 2) {
        Hardware = new Sprite(pX, pY, android,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, android,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 2) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        wrong();
                        question();

                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 3) {
        Hardware = new Sprite(pX, pY, usb,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, usb,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 3) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        wrong();
                        question();

                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 4) {
        Hardware = new Sprite(pX, pY, google,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, google,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 4) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        question();
                        wrong();
                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 5) {
        Hardware = new Sprite(pX, pY, ram,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, ram,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 5) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        question();
                        wrong();
                    }
                    return true;
                }
                return true;
            };
        };
    } else if (r == 6) {
        Hardware = new Sprite(pX, pY, cd,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, cd,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 6) {
                        score();
                        remove();
                        question();
                    } else {

                        remove();
                        wrong();
                        question();
                    }
                    return true;
                }
                return true;
            }

        };
    } else if (r == 7) {
        Hardware = new Sprite(pX, pY, samsung,
                this.getVertexBufferObjectManager());
        body = PhysicsFactory.createBoxBody(this.mPhysicsWorldg, Hardware,
                BodyType.DynamicBody, boxFixtureDef);
        mHardware[active] = new Sprite(pX, pY, samsung,
                this.getVertexBufferObjectManager()) {
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                    float X, float Y) {
                if (pSceneTouchEvent.isActionDown()) {
                    if (a == 7) {
                        score();
                        remove();
                        question();
                    } else {
                        remove();
                        wrong();
                        question();
                    }
                    return true;
                }
                return true;
            };
        };
    }

    mHardwareBody[active] = PhysicsFactory.createBoxBody(
            this.mPhysicsWorldg, mHardware[active], BodyType.DynamicBody,
            boxFixtureDef);

    scene.attachChild(mHardware[active]);

    this.mPhysicsWorldg.registerPhysicsConnector(new PhysicsConnector(
            mHardware[active], mHardwareBody[active], true, false));

    Vector2 velocity = Vector2Pool.obtain(-1, -16);
    body.setTransform(velocity, 85);
    mHardwareBody[active].setLinearVelocity(velocity);
    Vector2Pool.recycle(velocity);
    this.scene.registerTouchArea(mHardware[active]);

}
4

1 回答 1

4

某些东西已损坏或未初始化。0xdeadbaad看起来像那些调试/哨兵地址之一,例如0xdeadbeefor 0xbaadf00d

您可能想要研究的是堆损坏。根据Wikipedia HexSpeak 页面

0xDEADBAAD当检测到本机堆损坏时,Android libc abort() 函数会使用 ("dead bad")。

您的问题中没有足够的信息来提供解决此类问题的具体指导,可能值得联系 AndEngine 团队以了解他们的想法,假设这是由他们的代码(或您的代码间接通过他们的代码)引起的。

于 2013-05-22T07:45:43.503 回答