全面的理解cocos+Lua的绑定关系需要更加深入理解cocos和lua的交互中所操作的表(table),这些表大多存在于注册表中。
首先来看cocos中的对象对应lua中的userdata,绑定的元表
以cc.Sprite为例
["cc.Sprite"] = {--table: 0x0032c690
["new"] = "function: 0x00b9b168",
["__lt"] = "function: 0x0032cbf0",
["__sub"] = "function: 0x0032cc58",
["__newindex"] = "function: 0x0032c710",
["__eq"] = "function: 0x0032cc30",
["__le"] = "function: 0x0032cc10",
["createWithSpriteFrame"] = "function: 0x00b9be50",
["createWithSpriteFrameName"] = "function: 0x00b9be00",
["tolua_ubox"] = "table: 0x002c86f0" , -- loop table,
["createWithTexture"] = "function: 0x00b9b5c0"
["__div"] = "function: 0x0032c6b8",
["__index"] = "function: 0x0032c6f0",
["__gc"] = "function: 0x002c1a90",
["__call"] = "function: 0x0032cc98",
["__mul"] = "function: 0x0032cc78",
["__add"] = "function: 0x0032c730",
[".metatable"] = table: 0x002ca9c8,
......
},
["cc.Node"] = {--table: 0x002ca9c8
["visit"] = "function: 0x002cc550",
["setVisible"] = "function: 0x002cddb8",
["__index"] = "function: 0x002c7ec8",
["getPosition"] = "function: 0x010b3bf8",
["setPosition"] = "function: 0x002cccb8",
["setRotation"] = "function: 0x002cc030",
["create"] = "function: 0x002cd220",
["init"] = "function: 0x002cbfa8",
["__newindex"] = "function: 0x002c7ee8",
["__call"] = "function: 0x002cb588",
["__eq"] = "function: 0x002cb650",
["__add"] = "function: 0x002c7f08",
["__sub"] = "function: 0x002ca9f0",
["__gc"] = "function: 0x002c1a90",
["__lt"] = "function: 0x002c7f48",
["__mul"] = "function: 0x002caa10",
["__le"] = "function: 0x002c7f68",
["tolua_ubox"] = "table: 0x002c86f0" , -- loop table,
["__div"] = "function: 0x002c7f28",
["new"] = "function: 0x002c9e50",
["addChild"