简体   繁体   English

垄断棋盘游戏的Java最佳GUI方法

[英]Best GUI Approach with Java for a Monopoly Board Game

I have a project to create a multi-player monopoly game I have a pretty good idea how to implement it but until now I had practically no experience with GUIs. 我有一个创建多人垄断游戏的项目,我有一个很好的实现方法,但是直到现在我几乎还没有使用GUI的经验。 What I want to do is I want the board to look pretty realistic so my main concerns are is SWING capable of providing me with: 我想做的是让董事会看起来很现实,所以我主要关心的是SWING是否能够为我提供:

a) clickable squares (supporting right click menus) and a background image a)可点击的方块(支持右键菜单)和背景图片

b) moving pieces (a "float from one square to another" animation would be nice) which would stay over a square and would support right click menus b)移动块(一个“从一个正方形浮动到另一个正方形的动画”会很不错),它将停留在一个正方形上并支持右键单击菜单

c) Pop up menus with a radio button. c)弹出带有单选按钮的菜单。

Basically my main concern is the floating piece animation and the rolling dice animation (ok the last one is not so important). 基本上,我主要关心的是浮动动画和掷骰子动画(好吧,最后一个并不是那么重要)。

If I can't do that with SWING can I do that with QT? 如果我不能使用SWING做到这一点,那么我可以利用QT做到这一点吗?

Yes, you can do all of those with Swing. 是的,您可以使用Swing完成所有这些操作。 You can use AWT too if you choose. 您也可以选择使用AWT。

I wrote a simple chess game in Java. 我用Java编写了一个简单的国际象棋游戏。 Here is the link: http://www.kanersan.com/myfiles/ChessSource.zip 这是链接: http : //www.kanersan.com/myfiles/ChessSource.zip

It has a simple GUI. 它有一个简单的GUI。

Enjoy. 请享用。

You can easily do that in SWING using Graphics2D All what you need is to understand how to paint some graphics and animate them. 您可以使用Graphics2D在SWING中轻松地做到这一点。所有您需要的是了解如何绘制某些图形并将它们设置为动画。 This tutorial should be of a good help to you. 教程应该对您有很好的帮助。

The Swing library should be fine to use. Swing库应该很好用。 It contains all of the GUI components you mention plus more. 它包含您提到的所有GUI组件以及更多内容。

When you mention animation, with pieces floating from one square to another, if they are going to be overlapping, passing through, or landing on some of your GUI components (like, if you plan on having the GUI components as part of the gameboard, as opposed to a side menu of game options), then I might suggest looking into rendering Swing with your game's graphics at the same time, so the graphics can appear on top or on bottom of whatever components you have when needed. 当您提到动画时,如果棋子从一个正方形浮到另一个正方形,如果它们将重叠,穿过或着陆在您的某些GUI组件上(例如,如果您计划将GUI组件作为游戏板的一部分,而不是游戏选项的侧面菜单),那么我建议您同时考虑使用游戏的图形来渲染Swing,这样图形就可以在需要时显示在任何组件的顶部或底部。

You can find a tutorial on setting up a frame with game like graphics while rendering Swing at the same time here (the method in the tutorial uses active rendering, which is preferable when wanting smooth time based animations, such as the dice roll you want): 您可以在此处找到有关在同时渲染Swing的同时使用图形之类的游戏设置框架的教程(该教程中的方法使用主动渲染,这在希望基于平滑时间的动画(例如所需的骰子滚动)时更可取)。 :

http://www.jamesgames.org/resources/double_buffer/double_buffering_and_active_rendering.html http://www.jamesgames.org/resources/double_buffer/double_buffering_and_active_rendering.html

带有游戏图形/板等的嵌入式秋千
(source: jamesgames.org ) (来源: jamesgames.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM