Java – libgdx: set another screen, but still the button activated from the old screen

In my libgdx game, I have 2 screens, menus and lists

But when I click the same location (from the menu screen where the tags are located, but of course these tags are not displayed because I have changed the screen), the click event will respond Why?

Note: the my list screen currently does not have any widget event handlers

When switching screens, do I need to do more than just set up the screen (other screens) to disable the old screen?

Solution

I changed this:

I use the stage variable of this screen to move the input processor to the show () method of this screen

public void show() {
    ...
    Gdx.input.setInputProcessor(stage);

}

Before I set it only in the constructor of the screen, so even if I'm changing the screen, the input processor still attaches to the stage of the last created screen

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>