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
