Flixel - FlxButton 的行为就像多次单击一样
我有几个由 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将
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.我刚刚了解了
FlxGroup
的基本事实:将组设置为 active:false != 将组中的每个成员设置为 active:false。假设您有一个
FlxGroup
,其中包含一堆FlxButton
。如果您单击某个按钮,结果之一是FlxGroup
设置为active = false
,则该按钮本身仍处于活动状态。解决方案:调用...
这会将
FlxGroup
的每个成员设置为active = false
,并且按钮将知道它不可能被单击。资料来源:funstorm -请参阅解决方案 #2
Basic truth I've just learned about
FlxGroup
s: Setting a group to active:false != setting each member of the group to active:false.Say you have a
FlxGroup
with a bunch ofFlxButton
s in it. If you click a button and one of the results is thatFlxGroup
gets set toactive = false
, the button itself is still active.The solution: call...
This will set each member of the
FlxGroup
toactive = false
, and the button will know it can't possibly be clicked.Source: funstorm - See solution #2