Android 如何使场景更新处理程序在操作启动(AndEngine)时中断?

Android 如何使场景更新处理程序在操作启动(AndEngine)时中断?,android,handler,andengine,Android,Handler,Andengine,我正在尝试使用更新处理程序来增加精灵的规模。但是,它不允许调用场景动作启动事件,因此精灵的大小将继续增加。当操作启动时,如何使更新处理程序中断?这就是我所拥有的: 更新处理程序: scene.registerUpdateHandler(new IUpdateHandler() { @Override public void reset() { } @Override public void on

我正在尝试使用更新处理程序来增加精灵的规模。但是,它不允许调用场景动作启动事件,因此精灵的大小将继续增加。当操作启动时,如何使更新处理程序中断?这就是我所拥有的:

更新处理程序:

scene.registerUpdateHandler(new IUpdateHandler() {

        @Override
        public void reset() {         
        }

        @Override
        public void onUpdate(float pSecondsElapsed) {
            if(fillerNum>-1){
                if(filler[fillerNum].active){

                    mPhysicsWorld.unregisterPhysicsConnector(mPhysicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(filler[fillerNum].sprite));
                    mPhysicsWorld.destroyBody(filler[fillerNum].body);

                    filler[fillerNum].sprite.setScale(filler[fillerNum].scale+=pSecondsElapsed*3);

                    filler[fillerNum].body = PhysicsFactory.createCircleBody(mPhysicsWorld, filler[fillerNum].sprite, BodyType.DynamicBody, FIXTURE_DEF);
                    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(filler[fillerNum].sprite, filler[fillerNum].body, true, true));
                }
            }               
        }
    });
和场景触摸事件:

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
     if(this.mPhysicsWorld != null) {
            if(pSceneTouchEvent.isActionDown()) {
                createFiller(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
                return true;
            }
            if(pSceneTouchEvent.isActionUp()){
                Log.e("Action UP", Boolean.toString(filler[fillerNum].active));
                createStationaryFiller();
            }
        }
    return false;
}

只需保存UpdateHandler的实例:

handler = new IUpdateHandler() {... etc

当你想停止它时,调用scene.unregisterUpdateHandler(handler)

只需保存UpdateHandler的实例:

handler = new IUpdateHandler() {... etc

当你想停止它时,调用scene.unregisterUpdateHandler(处理程序)

我考虑过这一点,但是我的isactionup从不注册(log语句从不执行),这就是我想调用scene.unregisterUpdateHandler(处理程序)的地方,对吗?当你抬起手指时,TouchEvent是否会触发?将一些日志输出放在if语句之前,请参阅。也许可以尝试检查pSceneTouchEvent.getAction()==MotionEvent.ACTION\u。我不认为这会有帮助,但值得一试。另外,记录pSceneTouchEvent.getAction()的值并告诉我您得到了什么。不,它没有。事实证明,我还需要在OnAreTouch方法中添加一个isactionup()。我考虑过这一点,但我的isactionup从不注册(log语句从不执行),这就是我想调用scene的地方。unregisterUpdateHandler(handler),对吗?当你举起手指时TouchEvent是否会触发?将一些日志输出放在if语句之前,请参阅。也许可以尝试检查pSceneTouchEvent.getAction()==MotionEvent.ACTION\u。我不认为这会有帮助,但值得一试。另外,记录pSceneTouchEvent.getAction()的值并告诉我您得到了什么。不,它没有。事实证明,我还需要在OnAreTouch方法中添加一个isactionup()和一个isactionup()。