2015-11-04 78 views
0
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個的控制器的圖片。模擬控制器不工作?

+0

我得到這個。只是我沒有對onPopulateScene()方法做出回調 – willnotquit

+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(); 

//這裏您需要回調我不知道如何解決這個問題,但它 解決上述問題...