Hi,
Lua binding for methods like PhysicsShapeEdgeBox::getPoints, PhysicsShapeEdgeChain::getPoints… doesn’t seem to work.
The getPoints function in Lua always returns nil and if I try to pass a table I get the following error.
getPoints has wrong number of arguments: 1, was expecting 1
Here is the Lua code to reproduce the issue.
local scene = cc.Scene:createWithPhysics()
scene:getPhysicsWorld():setDebugDrawMask(cc.PhysicsWorld.DEBUGDRAW_ALL)
scene:getPhysicsWorld():setGravity(cc.p(0,0))
local edgeBox= cc.Node:create()
edgeBox:setPhysicsBody(cc.PhysicsBody:createEdgeBox(cc.size(100,100)))
edgeBox:setPosition(cc.p(100,100))
scene:addChild(edgeBox)
print(edgeBox:getPhysicsBody():getFirstShape():getPointsCount()) -- ok 4
local points = edgeBox:getPhysicsBody():getFirstShape():getPoints()
print(points) -- nil
local points = {}
-- edgeBox:getPhysicsBody():getFirstShape():getPoints(points) -- KO
-- getPoints has wrong number of arguments: 1, was expecting 1
local poly = cc.Node:create()
poly:setPhysicsBody(cc.PhysicsBody:createPolygon({cc.p(100,250),cc.p(200,300),cc.p(200,250)}))
scene:addChild(poly)
for _,shape in ipairs(poly:getPhysicsBody():getShapes()) do
local count = shape:getPointsCount()
print(count) -- 3
for i=0, count - 1 do
local p = shape:getPoint(i)
print(p.x,p.y) -- ok
end
local points = shape:getPoints()
print(points) -- nil
end
local edgePoly = cc.Node:create()
edgePoly:setPhysicsBody(cc.PhysicsBody:createEdgePolygon({cc.p(300,150),cc.p(400,200),cc.p(400,150)}))
scene:addChild(edgePoly)
print(edgePoly:getPhysicsBody():getFirstShape():getPointsCount())
local points = edgePoly:getPhysicsBody():getFirstShape():getPoints()
print(points) -- nil
cc.Director:getInstance():replaceScene(scene)
Thanks in advance.