Analysis of transfer parameters of COCOS2DX Tolua

Source: Internet
Author: User

COCOS2DX Tolua Transfer parameter analysis: tolua_cocos2d_ccnode_addchild00 = = void Ccnode::addchild (Ccnode *child) Tolua_cocos2d_ccnode_ ADDCHILD01 = = void Ccnode::addchild (ccnode *child, int zOrder) tolua_cocos2d_ccnode_addchild02 = = void Ccnode::addchild ( Ccnode *child, int zOrder, int tag) above is the use of Tolua to the C + + to Lua, the above three respectively corresponding to the number of different parameters. Let's analyze the last one here:/* Method:addchild of Class Ccnode */#ifndef tolua_disable_tolua_cocos2d_ccnode_addchild02static int TOLUA_COCOS2D_CCNODE_ADDCHILD02 (lua_state* tolua_s) {tolua_error tolua_err;//here to determine whether the argument is legitimate, can only determine whether the parameter type is legitimate, if the parameter type check does not pass,     Will error if (!tolua_isusertype (tolua_s,1, "Ccnode", 0,&tolua_err) | |     !tolua_isusertype (tolua_s,2, "Ccnode", 0,&tolua_err) | |     !tolua_isnumber (tolua_s,3,0,&tolua_err) | |     !tolua_isnumber (tolua_s,4,0,&tolua_err) | | !tolua_isnoobj (Tolua_s,5,&tolua_err)) goto Tolua_lerror;  else {///For example: Middlebg:addchild (Testsprite, z_order_1, 200)//We pass in the parameters and the following one by one corresponds//Here you can see clearly the order of incoming parameters, the first is MIDDLEBG ... ccnode* self = (ccnode*) tolua_tousertype (tolua_s,1,0); --MIDDLEBG--1 ccnode* child = ((ccnode*) Tolua_tousertype (tolua_s,2,0));          --Testsprite--2 int zOrder = ((int) tolua_tonumber (tolua_s,3,0));             --z_order_1--3 int tag = ((int) tolua_tonumber (tolua_s,4,0)); ---4#ifndef tolua_release if (!self) tolua_error (tolua_s, "Invalid ' self ' in function ' AddChild '", NULL); #e  NDIF {//Here the Testsprite added to the MIDDLEBG self->addchild (Child,zorder,tag); }} return 0;tolua_lerror:return tolua_cocos2d_ccnode_addchild01 (tolua_s);} #endif//#ifndef tolua_disable Example://middlebg:addchild (Testsprite, z_order_1, 200) in the pass parameter, we do not assign a value to z_order_1, that is nil, then// The following error occurred, see here argument #3, indicating that it is the third parameter error, and here we are clearly the second parameter, look at the above analysis//I think we should understand that through this method, we will find this kind of problem later, it would be more convenient. 03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): LUA ERROR: [string "Xxxxxxxxxxxxx ..."]:171:error in function ' AddChild ' .03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): Argument #3 is ' nil '; ' [No object] ' expected.03-31 10:09:50.499:d/cocos2d-xDebug Info (3169): Stack traceback:03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): [C]: in function ' AddChild ' 03-31 10:09 : 50.499:d/cocos2d-x Debug Info (3169): [string "xxxxxxxxxxxxx ..."]:171:in function ' Initmiddle ' 03-31 10:09:50.499:d/ Cocos2d-x Debug Info (3169): [string "xxxxxxxxxxxxx ..."]:35:in function ' Initui ' 03-31 10:09:50.499:d/cocos2d-x debug inf O (3169): [string "xxxxxxxxxxxxx ..."]:27:in function ' ctor ' 03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): [string "xxx Xxxxxxxxxx "]:34:in function ' create ' 03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): [string" Xxxxxxxxxxxxx "]:38:in Fu Nction ' new ' 03-31 10:09:50.499:d/cocos2d-x Debug Info (3169): [string ' xxxxxxxxxxxxx ']:44:in function ' Pushscene ' 03-31 1 0:09:50.499:d/cocos2d-x Debug Info (3169): [string "xxxxxxxxxxxxx"]:309:in function ' CallBack ' 03-31 10:09:50.499:d/ Cocos2d-x Debug Info (3169): [string "xxxxxxxxxxxxx"]:653:in function <[string "xxxxxxxxxxxxx"]:651>

Analysis of transfer parameters of COCOS2DX Tolua

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.