【问题标题】:Analog controller not working?模拟控制器不工作?
【发布时间】:2015-11-04 13:07:49
【问题描述】:
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 次的图片。

【问题讨论】:

  • 我知道了。只是我没有对 onPopulateScene() 方法进行回调
  • 解决了吗?请您将其发布为您的答案,然后选择它并关闭问题:)

标签: java android andengine


【解决方案1】:
    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();

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

【讨论】:

    猜你喜欢
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    相关资源
    最近更新 更多