我是Lua和Corona的初学者,我正在努力教自己如何使用它。我现在有这个代码:
local physics = require("physics")
physics.start()
local cX = display.contentCenterX
local cY = display.contentCenterY
local ball = display.newCircle( cX, cY, 50 )
local rock = display.newRect( cX, 1200, 800, 100 )
rock:setFillColor( 0.5, 0.5, 0.5 )
local properties = { density=1.0, friction=0.3, bounce=1 }
physics.addBody( "ball", "dynamic", properties )
physics.addBody( "rock", "static", properties )
physics.setDrawMode( "debug" )
但是,当我运行它时,它会给我添加物理主体到球的这个错误:
ERROR: table expected. If this is a function call, you might have used '.' instead of ':'
我似乎无法弄清楚为什么会抛出错误。任何帮助表示赞赏!
听取错误信息,他们可能会提供帮助甚至回答,就像这次:If this is a function call, you might have used '.' instead of ':'
使用physics:addBody( "ball", "dynamic", properties )
,就像你在rock:setFillColor( 0.5, 0.5, 0.5 )
中所做的那样。实际上,a:b(c)
与a.b(a, c)
相同,并且当你必须在像这里的对象上调用方法时经常使用它。