简体   繁体   中英

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(“仍然按下”);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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