Flixel - FlxButton 的行为就像多次单击一样

发布于 2024-12-23 17:58:42 字数 543 浏览 0 评论 0原文

我有几个由 FlxGroups 制作的对话框屏幕。第一个屏幕 LandingScreen 有一个可打开第二个屏幕 CargoShop 的按钮。每当添加一个屏幕时,它就会成为我的 FlxState 中的活动屏幕,并且其他屏幕的按钮设置为 active = false; 因此,当按钮打开 CargoShop 时单击 code> 屏幕,在下一个更新周期将其设置为 active = false;

现在,CargoShop 屏幕有一个用于关闭它的按钮,这使得 LandingScreen 再次处于活动状态。由于某种原因,一旦 CargoShop 屏幕关闭,就会立即打开一个新屏幕,就像再次单击商店按钮一样。

这些按钮并不相互重叠。 FlxButton 是否缺少一些技巧,即认为它在没有被单击时被单击?只有当我使用鼠标时才会出现这种情况;如果我使用键盘命令关闭 CargoScreen,则不会立即创建新的。

I have a couple of dialog screens made from FlxGroups. The first screen, LandingScreen has a button that opens a second screen, CargoShop. Whenever a screen is added, it is made the active screen in my FlxState, and the other screens' buttons are set to active = false; So, when the button to open the CargoShop screen is clicked, it is set to active = false; at the next update cycle.

Now, the CargoShop screen has a button to close it, which makes the LandingScreen active again. For some reason, as soon as the CargoShop screen is closed, a new one is instantly opened as if the shop button had been clicked again.

These buttons are not on top of each other. Is there some trick I'm missing with FlxButton that is thinks it's clicked when it's not? It only happens when I use the mouse; if I close the CargoScreen with a keyboard command, a new one is not instantly created.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好久不见√ 2024-12-30 17:58:42

您可以将 mouseEnable = mouseChildren = false 设置为非活动屏幕,以确保其不会接收鼠标输入。尽管乍一看,您的问题似乎是一个逻辑问题。

You can set mouseEnable = mouseChildren = false to the non-active screen to make sure it will not receive mouse input. Although your issue seems - at first view - to be a logic trouble.

泛滥成性 2024-12-30 17:58:42

我刚刚了解了 FlxGroup 的基本事实:将组设置为 active:false != 将组中的每个成员设置为 active:false。

假设您有一个 FlxGroup,其中包含一堆 FlxButton。如果您单击某个按钮,结果之一是 FlxGroup 设置为 active = false,则该按钮本身仍处于活动状态。

解决方案:调用...

yourGroup.setAll("active", false);

这会将FlxGroup 的每个成员设置为active = false,并且按钮将知道它不可能被单击。

资料来源:funstorm -请参阅解决方案 #2

Basic truth I've just learned about FlxGroups: Setting a group to active:false != setting each member of the group to active:false.

Say you have a FlxGroup with a bunch of FlxButtons in it. If you click a button and one of the results is that FlxGroup gets set to active = false, the button itself is still active.

The solution: call...

yourGroup.setAll("active", false);

This will set each member of the FlxGroup to active = false, and the button will know it can't possibly be clicked.

Source: funstorm - See solution #2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文