3.2 lua绑定 为什么不好使??

MyTest.h
#pragma once
#include
#include “base/CCRef.h”
NS_CC_BEGIN
class MyTest : public Ref
{
public:
static MyTest* create();
MyTest(void);
virtual ~MyTest(void);
};
NS_CC_END

MyTest.cpp

#include “MyTest.h”
NS_CC_BEGIN
MyTest* MyTest::create()
{
MyTest * ret = new MyTest();
if (ret )
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}

MyTest::MyTest(void)
{
}

MyTest::~MyTest(void)
{
}
NS_CC_END

MyTest_LuaBinding.tolua
$#include “MyTest.h”
$using namespace cocos2d;

class MyTest : public cc.Ref
{
public:
static MyTest* create();
};

XX.bat

@echo off
set DIR=%~dp0
set OUTPUT_DIR=DIR
set MAKE_LUABINDING="QUICK_V3_ROOT\quick\bin\compile_luabinding.bat"
pushd
cd “DIR
call MAKE_LUABINDING -E CCOBJECTS=MyTest -pfx cc -d OUTPUT_DIR MyTest_LuaBinding.tolua

AppDelegate.cpp
void StartupCall::startup()
{
auto engine = LuaEngine::getInstance();
auto stack = engine->getLuaStack();
lua_State* L = stack->getLuaState();
luaopen_MyTest_LuaBinding(L);
。。。。。。。。。。。。。
}

调用:
function MainScene:onEnter()
local test = cc.MyTest:create()
end

全部代码 调用就是test是nil

搞定了 lua绑定的坑啊
http://www.cocoachina.com/bbs/read.php?tid=200145

auto stack = engine->getLuaStack();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
auto luaStack = engine->getLuaStack()->getLuaState();
if (luaStack)
{
lua_getglobal(luaStack, “_G”);
luaopen_MyTest_LuaBinding(luaStack);
lua_settop(luaStack, 0);
}

果然。。

:9::9: