模拟控制器不工作?

时间:2015-11-04 13:07:49

标签: java android andengine

final int x1=0;
final int y1= CAMERA_HEIGHT-(int)this.mOnScreenControlBaseTextureRegion.getHeight();
final AnalogOnScreenControl velocityOnScreenController = new AnalogOnScreenControl(x1, y1, this.mCamera,this.mOnScreenControlBaseTextureRegion, 
            this.mOnScreenControlKnobTextureRegion,0.1f,this.mEngine.getVertexBufferObjectManager(), new IAnalogOnScreenControlListener(){

                @Override
                public void onControlChange(
                        BaseOnScreenControl pBaseOnScreenControl,
                        float pValueX, float pValueY) {
                    // TODO Auto-generated method stub

                    spaceshipPhysicsHandler.setVelocity(pValueX * 50,pValueY * 50);

                }

                @Override
                public void onControlClick(
                        AnalogOnScreenControl pAnalogOnScreenControl) {
                    // TODO Auto-generated method stub
                    // do nothing on click

                }
        });
     this.mScene.setChildScene(velocityOnScreenController);

所有控制器底座和旋钮均已设定。它完美地出现在屏幕上,但问题是它什么也没做。它的旋钮不移动,永远不会调用onControllerChange()方法。我在这做什么错?我需要将它保存在某种更新方法()中吗?它就像控制器在第n页的图片一样。

1 个答案:

答案 0 :(得分:0)

    velocityOnScreenController.getControlBase().setBlendFunction(GL10.GL_SRC_ALPHA,  GL10.GL_ONE_MINUS_SRC_ALPHA);
    velocityOnScreenController.getControlBase().setAlpha(0.5f);
    velocityOnScreenController.setOnControlClickEnabled(true);

  this.mScene.setChildScene(velocityOnScreenController);
  OnPopulateSceneCallback.onPopulateSceneFinished();

//在这里你需要进行回调我不知道这是如何解决问题的  它解决了上述问题...