lua中如何使用getPixel、getColor方法

能有人展示一下在lua中正确使用getPixel和getColor的方法吗? 我尝试了

 pix = 5; piy = 5;
 getPixel(pix, piy) --getColor(pix, piy)

 image:getPixel(pix, piy) --image:getColor(pix, piy)

...但我就是无法理解lua在抱怨什么。

错误: attempt to call global 'getPixel' (a nil value)

点赞
用户2858170
用户2858170

请问有人能够向我展示如何正确使用 Lua 中的 getPixel 和 getColor 函数吗?

Lua 并没有提供获取像素或颜色的函数。就像你之前提到的,这是在 Gideros 手册中可以找到的。

getPixel(pix, piy) --image:getColor(pix, piy)

然而,我完全不知道 Lua 在抱怨什么。

错误:尝试调用全局变量 'getPixel'(一个空值)

Lua 抱怨你调用了一个空值。在你的全局环境中,并没有命名为 getPixel 的变量。

所以,请再次打开 Gideros 手册:

http://docs.giderosmobile.com/reference/gideros

然后,例如,点击左侧菜单中的 Pixel:

http://docs.giderosmobile.com/reference/gideros/Pixel#Pixel

2018-04-19 17:41:34