lua:25:尝试调用方法';setanchorPoint';(一个nil值)堆栈回溯:main.lua25:在maiin块中

lua:25:尝试调用方法';setanchorPoint';(一个nil值)堆栈回溯:main.lua25:在maiin块中,lua,coronasdk,Lua,Coronasdk,我发现一个错误:main.lua:25:尝试调用方法“setancorpoint”(一个nil值)堆栈回溯:main.lua25:在maiin块中。请告诉我如何使用anchorPoint。如何解决这个问题? --constants _H = display.contentHeight; _W = display.contentWidth; mRand = math.random; o = 0; time_remain = 10; time_up = false; total_orbs = 20;

我发现一个错误:main.lua:25:尝试调用方法“setancorpoint”(一个nil值)堆栈回溯:main.lua25:在maiin块中。请告诉我如何使用anchorPoint。如何解决这个问题?

--constants
_H = display.contentHeight;
_W = display.contentWidth;
mRand = math.random;
o = 0;
time_remain = 10;
time_up = false;
total_orbs = 20;
ready = false;
--Prepare sounds to be played or accessed
local soundtrack = audio.loadStream("media/soundtrack.caf");
local pop_sound = audio.loadSound("media/pop.caf");
local win_sound = audio.loadSound("media/win.caf");
local fail_sound = audio.loadSound("media/fail.caf");

local display_txt = display.newText("Wait", 0, 0, native.systemFont, 16*2);
display_txt.xScale = .5; display_txt.yScale = .5;
display_txt:setanchorPoint(display.BottomLeftanchorPoint);
display_txt.x = 20; display_txt.y = _H-20;

如果您想知道如何在Corona中使用定位点,通常的方法是参考Corona手册

锚定

对象的定位点控制几何体的定位方式 相对于对象的原点这是通过指定的 object.anchorX和object.anchorY属性

他们甚至举例说明


你不能只发明函数名就想知道为什么调用它们会收到错误消息。

我在corona文档中找不到函数
setanchorPoint
,我只是用引用对象替换了锚。下面是代码。请查看它。local display_txt=display.newText(“Wait”,0,0,native.systemFont,16*2);显示_txt.xScale=.5;显示_txt.yScale=.5;display_txt:setanchorPoint(display.BottomLeftanchorPoint);显示_txt.x=20;显示_txt.y=_H-20;编辑你的问题。不要在注释中添加代码。。。请你读一下好吗?这是你不阅读手册的习惯让你来到这里。因此,如果您没有阅读Corona手册,请您至少阅读StackOverflow的指南好吗?