【问题标题】:LibGdx inputProcessors touchDown is playing upLibGdx inputProcessors touchDown 正在播放
【发布时间】:2014-03-30 16:41:44
【问题描述】:

嗨,我有这个球,我试图通过 touchDown 方法保持在空中。这确实对我有用,但它并不一致,因为我必须反复点击屏幕才能让它说话,有时它什么也没做。

        Gdx.input.setInputProcessor(new InputController(){
        @Override
        public boolean touchDown(int screenX, int screenY, int pointer, int button){
            random = new Random();
            int rand = random.nextInt(2);
            Vector3 mouseCoords = new Vector3(screenX, screenY, 0);
            camera.unproject(mouseCoords);
            mouseCoords.scl(WORLD_TO_BOX);


            if(ball.getFixtureList().get(0).testPoint(mouseCoords.x, mouseCoords.y)){
                movement.y = upPos;
                if(rand == 1){
                    movement.x = speedPos;
                }else if(rand == 0){
                    movement.x = speedMinus;
                }

                System.out.println("Reached the loop");
            }
            return true;                
        }
        @Override
        public boolean touchUp(int screenX, int screenY, int pointer, int button){
            movement.x = 0.00f;
            movement.y = 0.00f;
            return false;
        }

    });

我有一个名为 inputController 的类,它扩展了 InputProcessor,因此我可以挑选我想要使用的控件。我不知道是重力不允许形状向上移动还是代码没有触发。

有什么想法吗?

【问题讨论】:

    标签: java android libgdx box2d


    【解决方案1】:

    没关系,现在我想通了。我的盒子到世界的计算有点偏离

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 2017-01-22
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多