Re: I need some help on extended class

feng qiu <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
If you intend to call the parent function, try this:
CCLayer.addChild(self,ccnd)

On 25 May 2011 19:03, Zhimeng Wang <[email protected]> wrote:

> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>


-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.