2D 阵列图像交换
我有一个如何在我的 3 * 3 数组中交换图像的问题,例如:
mImage image1 image2
image3 image4 image5
image6 image7 image8
mImage 是我想与其余图像交换的图像,我只能与下一个图像交换或下面的(有点像益智游戏)。
所以mImage只能与image1和image3交换。
我的想法是点击鼠标时与 i+1 或 i+3 交换。
这是一个好的技术还是有更好的方法来解决这个问题?
谢谢
i have a problem of how to swap images isnide my 3 * 3 array, for example:
mImage image1 image2
image3 image4 image5
image6 image7 image8
mImage is the one i would like to swap with the rest, I can swap it only with the next one or with the one below(Sort of like a puzzler).
So the mImage can be swap only with image1 and image3.
What i thought is to swap with i+1 or with i+3 when the mouse is clicked.
Is that a good technique or is there a better approach to this problem?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单击图像时,检查它是否位于
mImage
旁边(即它的 X 坐标与 mImage.X 相同且 Y 坐标差等于 1,或者反之亦然)。如果是真的的话就可以换。When an image is clicked, check if it's next to
mImage
(i.e. either it's X coordinate is the same as mImage.X and the difference in Y coordinates is equal to 1, or the other way round). If it's true, then you can swap.