I register a c++ class CCLayer
luabind::module(L)[
class_<CCLayer,CCNode,CCLayer_wrap,boost::shared_ptr<CCLayer> >("CCLayer") .def(constructor<>()) .scope[ def("node",&CCLayer::node) ] .def("init", &CCLayer::init, &CCLayer_wrap::default_init) .def("addChild",(void(CCLayer::*)(CCNode * ))&CCLayer::addChild,&CCLayer_wrap::default_addChild) ]; then
extends it on lua script:
"class 'HelloWorld' (CCLayer)\n"
" function HelloWorld:__init() CCLayer.__init(self) end\n" " function HelloWorld:addChild(ccnd) printLog('addChild') ss = self.super ss:addChild(ccnd) end\n" " function HelloWorld:init() " " printLog('HelloWorld:init()')" " ccs = CCSprite()" " printLog('ccs = CCSprite()')" " ccs:initWithFile('HelloWorld.png')" " printLog('ccs:initWithFile1')" " self:addChild(ccs)" " printLog('self:addChild')" " end\n" but ss:addChild(ccnd) didn't work.
Could you tell me why?
-- Wang Zhimeng Software Engineer ,Borqs Software Limited Voice:+86-0150-1043-0531 Office: +86-10-8885-0518-8286 ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
If you intend to call the parent function, try this:
CCLayer.addChild(self,ccnd) On 25 May 2011 19:03, Zhimeng Wang <[hidden email]> wrote:
-- Q.. ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ luabind-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/luabind-user |
Free forum by Nabble | Edit this page |