mirror of https://github.com/axmolengine/axmol.git
issue #707: require works ok on android
This commit is contained in:
parent
86536c3683
commit
d6cc12ffe4
|
@ -1,3 +1,7 @@
|
|||
require "hello2"
|
||||
|
||||
cocos2d.CCLuaLog("result is " .. myadd(3, 5))
|
||||
|
||||
-- create scene & layer
|
||||
layerFarm = cocos2d.CCLayer:node()
|
||||
layerFarm:setIsTouchEnabled(true)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
function myadd(x, y)
|
||||
return x + y
|
||||
end
|
|
@ -5,6 +5,7 @@ LOCAL_MODULE := game
|
|||
LOCAL_SRC_FILES := main.cpp \
|
||||
../../../Classes/AppDelegate.cpp \
|
||||
../../../../lua/cocos2dx_support/LuaEngineImpl.cpp \
|
||||
../../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \
|
||||
../../../../lua/cocos2dx_support/LuaCocos2d.cpp \
|
||||
../../../../lua/cocos2dx_support/LuaEngine.cpp \
|
||||
../../../../lua/CocosDenshion_support/LuaSimpleAudioEngine.cpp
|
||||
|
|
|
@ -204,6 +204,14 @@
|
|||
<Filter
|
||||
Name="cocos2dx_support"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\lua\cocos2dx_support\Cocos2dxLuaLoader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lua\cocos2dx_support\Cocos2dxLuaLoader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lua\cocos2dx_support\LuaCocos2d.cpp"
|
||||
>
|
||||
|
|
|
@ -24,6 +24,8 @@ THE SOFTWARE.
|
|||
#include "Cocos2dxLuaLoader.h"
|
||||
#include <string>
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int loader_Android(lua_State *L)
|
||||
|
@ -44,7 +46,8 @@ extern "C"
|
|||
|
||||
if (luaL_loadstring(L, pCodes) != 0)
|
||||
{
|
||||
loaderror(L, filename.c_str());
|
||||
luaL_error(L, "error loading module %s from file %s :\n\t%s",
|
||||
lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1));
|
||||
}
|
||||
delete []pCodes;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
2f3177b8c1aed41dddecde3c7c39a724043b1283
|
||||
cdf713db9488ce1e7bdc010eced37ac848442735
|
|
@ -134,7 +134,7 @@ void CCLuaScriptModule::addLuaLoader(lua_CFunction func)
|
|||
|
||||
// insert loader into index 2
|
||||
lua_pushcfunction(d_state, func); // package, loaders, func
|
||||
for (int i = lua_objlen(L, -2) + 1; i > 2; --i)
|
||||
for (int i = lua_objlen(d_state, -2) + 1; i > 2; --i)
|
||||
{
|
||||
lua_rawgeti(d_state, -2, i - 1); // package, loaders, func, function
|
||||
// we call lua_rawgeti, so the loader table now is at -3
|
||||
|
|
Loading…
Reference in New Issue