Libgdx:设置另一个屏幕,但仍从旧的屏幕按键活跃 [英] Libgdx : setting another screen, but still buttons from old screen active

查看:199
本文介绍了Libgdx:设置另一个屏幕,但仍从旧的屏幕按键活跃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我libgdx 游戏,我有2个屏幕,菜单列表
当我点击菜单屏幕在标签上,我做了 setscreen(名单)
新的屏幕显示出来,并且在菜单画面非常久远的标签消失。

In my libgdx game, I have 2 screens, menu and list. When I click on a label in the menu screen, I do a setscreen(list). The new screen shows up, and the menu screen alongwith its labels disappears.

但是,当我在相同的位置单击(从菜单屏幕,标签分别为,但当然这些标签都没有显示,因为我已经改变屏幕)单击事件作出响应。为什么呢?

But when I click on the same positions (from menu screen where the labels were, but of course those labels are not showing as I have changed screens) the click event responds. Why?

请注意:我的列表屏幕目前没有任何控件事件处理程序。

note:My list screen currently has not event handlers for any widget.

当切换画面,我需要做任何事情,不仅仅是 setscreen(anotherscreen)停用oldscreen?

When switching screens do I need to do anything more than just setscreen(anotherscreen) to deactivate oldscreen?

推荐答案

我改变了这个:

我使用的屏幕级可变移动输入处理器到屏幕的show()方法

I moved the input processor to the show() method of that screen using stage variable of that screen

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

    }

我只是在屏幕的构造器设置这个,所以我就算是改变屏幕,输入处理器仍然附着在最后创建屏幕的阶段之前

before I was setting this only in the constructor of the screen, so even If I was changing the screen, the input processor was still attached to the last created screen's stage

这篇关于Libgdx:设置另一个屏幕,但仍从旧的屏幕按键活跃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆