mirror of https://github.com/axmolengine/axmol.git
adds "require" to the global namespace
This commit is contained in:
parent
8196324e38
commit
bed6efa3cd
|
@ -110,6 +110,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js");
|
||||
// ScriptingCore::getInstance().runScript("JS/1to1/test_bindings.js");
|
||||
// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js");
|
||||
// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
require("JS/1to1/test_require_second.js");
|
||||
|
||||
cocos.log("value: " + value);
|
|
@ -0,0 +1 @@
|
|||
value = "this was set in another file";
|
|
@ -207,6 +207,7 @@ ScriptingCore::ScriptingCore()
|
|||
S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine");
|
||||
|
||||
// register some global functions
|
||||
JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
|
Loading…
Reference in New Issue