在 LiveCode 中传递图像的 x,y 坐标
Passing x,y coordinates of an image in LiveCode
下面显示了我正在使用的 LiveCode 应用程序中其中一张卡片的屏幕截图。用户可以点击图标并在屏幕上移动它们,最好使用右侧的框对它们进行排序。为了记录图标的排名,我想得到他们的y坐标——即y坐标值越高,排名越低。不过,我对如何将图像的坐标传递给变量感到困惑。我是 LiveCode 的新手,非常感谢任何帮助。rating_screenshot
欢迎使用 LiveCode!
在 LiveCode 中你有一个属性:
the loc of image ”imagename”
您可以将其作为变量传递给过程。这将包含用逗号分隔的图像(或任何控件)的 x 和 y。要获得 y ,您需要获得其中的第二项。因此,您可以在程序中获取它,也可以在通过它时直接获取它。假设您有一个名为 saveOrder
的过程,您可以在其中以某种方式保存数据。您可以使用 y 坐标调用它,例如:
saveOrder item 2 of the loc of image “imagename”
如果你只是想抓取一些东西来确定哪个图像比另一个高,你可以使用 the top
或 the bottom
而不是 item 2 of the loc
。在字典中查找它们以获得进一步的解释...
PS the loc
是the location
的缩写,当然你喜欢也可以写出来
只是一个练习:在一张新卡片上制作两个按钮。在卡片脚本中:
on mouseMove
if "button" is in the name of the target and the mouse is down then
set the loc of the target to the mouseLoc
put item 2 of the loc of the target
end if
end mouseMove
单击按钮并将其拖动。拖动时,消息框中会出现按钮中心的"Y"坐标。当然,当你松开时,最后一个坐标会粘住。
正如 hliljegren 指出的那样,您可能不需要中心,而是感兴趣的控件的顶部或其他一些点。
您只需要:
on MouseDown
grab me
end MouseDown
Livecode 是世界上最简单高效的语言!
下面显示了我正在使用的 LiveCode 应用程序中其中一张卡片的屏幕截图。用户可以点击图标并在屏幕上移动它们,最好使用右侧的框对它们进行排序。为了记录图标的排名,我想得到他们的y坐标——即y坐标值越高,排名越低。不过,我对如何将图像的坐标传递给变量感到困惑。我是 LiveCode 的新手,非常感谢任何帮助。rating_screenshot
欢迎使用 LiveCode!
在 LiveCode 中你有一个属性:
the loc of image ”imagename”
您可以将其作为变量传递给过程。这将包含用逗号分隔的图像(或任何控件)的 x 和 y。要获得 y ,您需要获得其中的第二项。因此,您可以在程序中获取它,也可以在通过它时直接获取它。假设您有一个名为 saveOrder
的过程,您可以在其中以某种方式保存数据。您可以使用 y 坐标调用它,例如:
saveOrder item 2 of the loc of image “imagename”
如果你只是想抓取一些东西来确定哪个图像比另一个高,你可以使用 the top
或 the bottom
而不是 item 2 of the loc
。在字典中查找它们以获得进一步的解释...
PS the loc
是the location
的缩写,当然你喜欢也可以写出来
只是一个练习:在一张新卡片上制作两个按钮。在卡片脚本中:
on mouseMove
if "button" is in the name of the target and the mouse is down then
set the loc of the target to the mouseLoc
put item 2 of the loc of the target
end if
end mouseMove
单击按钮并将其拖动。拖动时,消息框中会出现按钮中心的"Y"坐标。当然,当你松开时,最后一个坐标会粘住。
正如 hliljegren 指出的那样,您可能不需要中心,而是感兴趣的控件的顶部或其他一些点。
您只需要:
on MouseDown
grab me
end MouseDown
Livecode 是世界上最简单高效的语言!