AndEngine:sprite上的更新处理程序

时间:2012-04-20 07:38:36

标签: android andengine

我是新手和发动机,因为从快两周开始使用它。我正在开发球赛,我的要求如下:当球第二次接触地面时它应该被摧毁。我尝试使用球精灵上的更新处理程序,当计数达到2时它工作正常(我明确地调用删除逻辑)。当它接触到地面体时,我在Update()处理器的计数器帮助下破坏球体。不幸的是,第一次碰撞(第一次碰撞时计数达到2)身体也被摧毁了。上面的场景经常重复,与联系人听众合作,但没有变化。任何帮助都将不胜感激。

@Override
public void onUpdate(float pSecondsElapsed) {
Shape path = new Rectangle(ballSprite.getX(),ballSprite.getY(), 10, 10);
if (ballCount <= 2) {
                mScene.attachChild(path);
                pathCoordinates.add(path);
                dumpPathCoordinates.add(path);
            }
            if (ballSprite.collidesWith(ground)) {
                ballCount++;
                if (ballSprite.collidesWith(ground) && ballCount == 2) {
                    removePath();
                    removeBall(ballSprite);
                    addFace(10, 10);
                }
            }
        }

1 个答案:

答案 0 :(得分:1)

第一次触摸可能比一次引擎迭代持续时间更长吗?如果是这样,只有在发生此序列时才需要允许移除球 touching->not touching->touching。 到目前为止,即使顺序是球,球也被移除 touching->still touching

相关问题