Cocos2dx 3.0自定义的类绑定到Lua ,一定要继承自Ref吗?

Cocos2dx 3.0自定义的类绑定到Lua ,一定要继承自Ref吗?

错误log:cocos\scripting\lua-bindings\manual\luabasicconversions.h(325): error C2683: “dynamic_cast”:“A”不是多态类型

我随便定义的 两个类 A 、B:

class A
{
public:
A(int a):m_pA(a){}
int getA()
{

return m_pA;
}

void setA(int a)
{
m_pA = a;
}

private:
int m_pA;
};

class B
{

public:

B(){}
void push(A* pA)
{
m_Names.push_back(pA);
}

A* getValue(int index)
{
return m_Names;
}
private:
vector<A*> m_Names;

};

绑定后,其中一段为:
int lua_Test_B_getValue(lua_State* tolua_S)
{
int argc = 0;
B* cobj = nullptr;
bool ok = true;

#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif

#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,“B”,0,&tolua_err)) goto tolua_lerror;
#endif

cobj = (B*)tolua_tousertype(tolua_S,1,0);

#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,“invalid ‘cobj’ in function ‘lua_Test_B_getValue’”, nullptr);
return 0;
}
#endif

argc = lua_gettop(tolua_S)-1;
if (argc == 1) 
{
    int arg0;


    ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
    if(!ok)
        return 0;
    A* ret = cobj->getValue(arg0);
  object_to_luaval<A>(tolua_S, "A",(A*)ret);//编译错误 是因为调用这个方法 里有一句 cocos2d::Ref* dynObject = dynamic_cast<cocos2d::Ref *>(ret); 
    return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValue",argc, 1);
return 0;

#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function ‘lua_Test_B_getValue’.",&tolua_err);
#endif

return 0;

}

可以不继承,不过要在conversions.yaml里面加上处理,不然默认就是object_to_luaval