问题描述
我正在开发一款游戏,我需要放置一张地图(静态)。需要遍历此地图中的城市。
我想知道是否有人可以帮助我以下内容:
1.如何将地图放在面板上? (使用什么......)
2.如何在掷骰子的过程中逐步遍历它? (移动应该是自动生成的,即不允许用户在板上拖动他的大理石。)
hi , I am developing a game wherein i need to place a map( static ). The cities in this map need to be traversed .
I was wondering if anybody could help me with the following :
1. how do I place the map on the panel ? ( using what.... )
2. How do i traverse it step by step on the roll of a dice? ( the moves should be auto generated i.e. the user is not allowed to drag his marble on the board .)
推荐答案
您可以将该地图表示为一个简单的图像,您可以在你的JPanel中画画。
弹珠最好是在JFrame本身的''glasspanel'上绘制的;然后它们出现在地图的顶部上。在JFrame的API文档中阅读所有相关内容。
亲切的问候,
Jos
You could represent that map as a simple image which you can draw in your JPanel.
The marbles are best drawn on the ''glasspanel'' of the JFrame itself; they appear
''on top'' of the map then. Read all about it in the API documentation of the JFrame.
kind regards,
Jos
您走在正确的轨道上:玻璃窗格是所有
$前面的非透明窗格b $ b JFrame中的其他内容。您应该将JPanel设置为非透明且可见:
You''re on the right track: a glass pane is a non-opaque pane in front of all the
other stuff in your JFrame. You should set your JPanel non-opaque and visible:
这篇关于使用画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!