class CControl //: public CGameObject
{
public:
CControl(){}
~CControl(){}
public:
void AddAnimation(){ cout << "CControl::AddAnimation" << endl;}
};
int _tmain()
{
lua_State* L = lua_open();
luaL_openlibs(L);
open(L);
module(L)
[
class_<CControl>("CControl")
.def(constructor<>())
.def("AddAnimation",&CControl::AddAnimation)
];
int result = luaL_dofile(L,"scripts/test.lua");
cout << result << endl;
return 0;
}
class 'Button' (Control)
function Button:__init()
Control:__init()
end
function Button:Create()
self:AddAnimation() --call, fail
end
d = Button()
d:Create()
当我调用继承函数self时:Button:Create中的AddAnimation()。 Wowwww! &#34; CControl :: AddAnimation&#34;打印出来了!到底发生了什么?我已经检查了2个小时。很好!真的很感激任何帮助
答案 0 :(得分:0)
我懂了!!如果要成功调用Controller构造函数,则必须编写如下代码
“Control.(self)
”。顺便说一下,当你想调用成员函数时,你应该写“self:AddAnimation
”