简体   繁体   English

libgdx如何在按下按钮时重复我的活动

[英]Libgdx how to repeat my event when the button is pressed

So i have a button on my app and when i press it the event triggers but i want it to repeat triggering as long as the button is pressed and not released 所以我在我的应用程序上有一个按钮,当我按下它时,事件会触发,但我希望它只要按下并释放就可以重复触发

        button.addListener(new InputListener(){
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub

            System.out.println(" still pressed");
            return true;
        }

    });

So here when i press the button i get " still pressed" but then i have to release the button and press it again to get the text "still pressed " to show in the console. 所以在这里,当我按下按钮时,我会“仍然按下”,但是随后我必须释放按钮,然后再次按下它,以使文本“仍然按下”显示在控制台中。 But i want it when i press the button and NOT release it will show multiple times in the console as long as i don't release it. 但是我想要当我按下按钮而不释放时,只要我不释放它,它将在控制台中显示多次。

如果(button.isPressed())System.out.println(“仍然按下”);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM