Search code examples
androidlibgdxstagescene2d

Stage response to touch


I want actors in a stage to respond to touch after specific time from the previous touch

e.g. I have an actor that responds to touch by doing some stuff and I want non of the other actors to respond to touch until 1 second has passed

How can I do this ?


Solution

  • Something like this might work, rough pseudocode and real code mixed together - more for illustration.

    ... previous touch actions finished
    stage.getRoot().setTouchable(Touchable.disabled);
    Timer.schedule(new Task(){
                    @Override
                    public void run() {
                        stage.getRoot().setTouchable(Touchable.enabled);
                    }
                   }
                   , 1.0f        //    (delay in seconds)
                  );