我正在JFrame中进行平铺,我只是认为如果地图的左上角是(0,0)会更容易处理,因为它可以更轻松地通过2d数组解释位置。
I'm doing some tiling in a JFrame
You should NOT be doing tiling in the frame.
Instead you add a JPanel
to the frame and do the tiling in the panel. Then the top/left of the panel will be(0, 0).
Read the section from the Swing tutorial . There are topics on:
Custom painting
- if you are painting your own tiles. The tutorial shows how to do custom painting on the panel
How to use GridLayout
- if you want to add real components to the panel.
In either case the frame is just a container for the panel. All the code/logic belongs in the panel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.