Call method setPosition from CCSprite,get error "attempt to call method 'setPosition' (a nil value)"

code segment:
function tick()
local velocityIterations=8
local positionIterations=1
world:Step(0.01,velocityIterations,positionIterations)//Box2d API:b2Word
b=world:GetBodyList()//Box2d API:b2Word
while b~=nil do
if b:GetUserData()~=nil then
myActor=b:GetUserData();
debug.setmetatable(myActor,cocos2d.CCSprite)//myActor is userdate type,change myActor to CCSprite type
myActor:setPosition(cocos2d:CCPointMake(b:GetPosition().x * ptmratio,b:GetPosition().y*ptmratio))
myActor:setRotation(–1*b:GetAngle())
end
b=b:GetNext();
end

i change a variable from userdate to CCSprite using “debug.setmetatable”,the variable can’t call setPosition method,who know this? Please help me!

class MyCocos2DClass : public cocos2d::CCSprite
local hsprite = MyCocos2DClass:createHSprite(“dog.png”)
cclog("hsprite = " … tostring(hsprite) ) – userdata: 0x10e64e50
–hsprite:setAnchorPoint(CCPoint(0,0))
hsprite:setPosition(100,100)
hsprite:setScale(1.5)
hsprite:setRotation(45)
layerH:addChild(hsprite)

hello.lua:193: attempt to call method ‘setPosition’ (a nil value)

how to fix it ?

tolua_cclass(tolua_S,“MyCocos2DClass”,“MyCocos2DClass”,“cocos2d::CCSprite”,NULL);

remove “cocos2d::” is ok now

tolua_cclass(tolua_S,“MyCocos2DClass”,“MyCocos2DClass”,“CCSprite”,NULL);