Java Swing-我该如何制作框架“必须与“与quot”互动?
我正在Java秋千上进行游戏。每次播放器上升时,我都会在包含游戏玩法的顶部显示一个新框架,该框架有一些选择,以获得升级的奖励。由于我的奖励性质,能够跳过选择一些升级的性质可能会破坏游戏,因此我想确保用户只能通过单击“升级框架”中显示的1-3个按钮之一来恢复播放。
我的框架设置为未装饰并始终显示在顶部,但是没有什么可以阻止用户单击其外部到主游戏玩法面板,然后简单地按下enc
恢复播放。相反,我想要它,以便用户只能单击2的升级帧。
是否可以为此切换一个简单的设置,还是必须从第一个面板中删除键盘输入侦听器才能实现此目标?
I'm making a game in Java Swing. Every time the player levels up I display a new frame on top of the one containing the gameplay which has some options on what rewards to get for having leveled up. Due to the nature of my rewards being able to skip choosing some of the upgrades could break the game, so I want to ensure that the user can only resume playing by clicking on one of the 1-3 buttons displayed in the level-up frame.
I have the frame set to undecorated and to appear always on top, but nothing's stopping the user from clicking outside of it to the main gameplay panel and simply pressing esc
to resume playing. Instead I want it so the user can only click on the level-up frame out of the 2.
Is there an easy setting I can toggle for this, or do I have to remove remove my keyboard input listener from the first panel to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论