Android:如何在网格上制作方形瓷砖夹
我是 Android 编程新手,有一些问题。我正在尝试创建一个瓷砖拼图游戏,我必须将方形瓷砖移动到网格中,并且瓷砖会自动夹到适当的位置。例如,我有一个 3x3 的方形网格,有 9 个位置。每个位置的尺寸为 100x100 像素。如果我将一个图块(也是 100x100 像素)拖动到网格内 9 个位置中的任何一个,该图块会自动夹在 100x100 像素区域内的适当位置,即使它有点偏离。我该怎么做?
I'm new to android programming and have some questions. I'm trying to create a tile puzzle game where I have to move squared tiles into a grid and the tiles would automatically clip onto place. For example, I have a 3x3 squared grid with 9 position. Each position measures 100x100 pixel. If I drag a tile(also 100x100 pixel) to any of the 9 positions inside the grid, the tile would automatically clip in place inside the 100x100 pixel area even if it's a bit off. How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,如果 x=140 y=260 则
由于 (int) ((int)(140/100)) 是 1 而不是 1.4,所以这样做的目的是将数字舍入
for example if you have x=140 y=260 then
Because of the (int) the ((int)(140/100)) is 1 not 1.4 so the point of this is to round the number