error in function 'addChild'.argument #2 is 'CGuideIntroductionLayer'; 'CCNode' expected.

i write a new class CGuideIntroductionLayer derived from CCLayer.when i use it in lua, such as

local pLayer = CGuideIntroductionLayer:create();
……
……
myScene:addChild(pLayer);

then it comes the error:error in function ‘addChild’.argument #2 is ‘CGuideIntroductionLayer’; ‘CCNode’ expected.

hope someone could help me, Thanks a lot a lot!

I had the same problem, the problem was that in my .pkg file it read:

class MyLayerClass : public cocos2d::CCLayer

To fix it, i changed it to:

class MyLayerClass : public CCLayer

are you sure if change cocos2d::CCLayer to CCLayer,the error would disappear? Because all my pkg files are using class A:public CCLayer.

Well, that fixed it for me, guess your root cause is different.

Maybe take a look at the tolua*+ class inheritence documentation, see if you can find the issue: http://www.codenix.com/~tolua/tolua*+.html#classes

Simon - wrote:

Well, that fixed it for me, guess your root cause is different.
>
Maybe take a look at the tolua*+ class inheritence documentation, see if you can find the issue: http://www.codenix.com/~tolua/tolua*+.html#classes

Thanks a lot.

Yingjian Chen wrote:

i write a new class CGuideIntroductionLayer derived from CCLayer.when i use it in lua, such as
>
local pLayer = CGuideIntroductionLayer:create();
……
……
myScene:addChild(pLayer);
>
then it comes the error:error in function ‘addChild’.argument #2 is ‘CGuideIntroductionLayer’; ‘CCNode’ expected.
>
hope someone could help me, Thanks a lot a lot!

I encountered a similar problem, how to solve!!!!