0

C++ code here, a console project

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;
}

lua code here using luabind

class 'Button' (Control)
function Button:__init()
    Control:__init()
end

function Button:Create()
    self:AddAnimation()    --call, fail 
end

d = Button()
d:Create()

Q:

when i call the inherited function self:AddAnimation() in the Button:Create. Wowwww! "CControl::AddAnimation" has't print out! what's going on? I have check it 2 hours.Frustrating! Any help would really be appreciated

enter image description here

1 Answers1

0

I get it!! If you want to call Control construtor successfully, you must write code like this "Control.(self)". And By the way, when you want to call memeber function, you should write "self:AddAnimation"