cocos2d-x3.0rc0 directory structure of new project is
frameworks
res
runtime
src
the ‘src’ and ‘res’ folder are copied to the path frameworks\runtime-src\proj.win32\Debug.win32\Resource after building the project in windows.
The project will run the lua source file in the inner ‘src’ folder, frameworks\runtime-src\proj.win32\Debug.win32\Resource\src.
So if I modify the lua source file in the outer ‘src’ folder, the project cannot find, unless I rebuild the project.
It is inconvenient.
why do you modify your lua srouce file out of src
?
if you have to you can change the vs setting
of pre build event
to do your own copy work.
You can find a cpp file to input a space,then build.This method can trigger pre build evnet
.Other method,you can look the vs setting to find Custom generation step
to try.
@moremorefun
my project path is F:\cocos2d-x-test\mygame-cocos3.0
which contains
frameworks
res
runtime
src
i mean if i modify lua file in F:\cocos2d-x-test\mygame-cocos3.0\src , i must rebuild the project.
if i don’t, just run the project, the project will run lua file in F:\cocos2d-x-test\mygame-cocos3.0\frameworks\runtime-src\proj.win32\Debug.win32\Resource\src. it cannot read my modify.
Yes, it is.
But you can write your own script[.bat, .py] to copy you lua file to the Resource
dir, and run the .exe
.
@moremorefun
i change the vs configure “Working Directory” to root path of my project, F:\cocos2d-x-test\mygame-cocos3.0\
and create a new folder called “cocoslib” in F:\cocos2d-x-test\mygame-cocos3.0\src
then copy the .lua which cocos generate in F:\cocos2d-x-test\mygame-cocos3.0\frameworks\runtime-src\proj.win32\Debug.win32\Resource to F:\cocos2d-x-test\mygame-cocos3.0\src\cocoslib
change the ‘require’ function in those lua file, exp. require"Cocos2d.lua" to require “src.cocoslib.Cocos2d.lua”
change the c++ code CCLuaEngine.cpp bool LuaEngine::init(void)
executeScriptFile(“src/cocoslib/DeprecatedEnum.lua”);
executeScriptFile(“src/cocoslib/DeprecatedClass.lua”);
executeScriptFile(“src/cocoslib/Deprecated.lua”);
I think copy the src
files to Debug.win32
is a better way.
@moremorefun
the copy way is inconvenient, cause if i modify a little in lua file, i’ll do the copy. that’s annoying.
maybe you think i can modify lua file directly in debug.win32 path. that’s not a good idea, cause if i modify the cpp file and rebulid the project, the modified lua files in debug.win32 path are gone.
@zhang06fan,I modify the configs of vs as follow:
1.set project director:$(ProjectDir)..\..\..
2.go to pre build event
to set:xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script" "$(ProjectDir)..\..\..\" /e /Y
In this way,you can modify your lua files in outer folders then run the project without building project.