diff --git a/templates/lua-template-default/runtime/ios/ios-sim b/templates/lua-template-default/runtime/ios/ios-sim deleted file mode 100755 index 51a7a05fd8..0000000000 Binary files a/templates/lua-template-default/runtime/ios/ios-sim and /dev/null differ diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp index 8bd26e143a..28933e0fdc 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -38,10 +38,6 @@ bool AppDelegate::applicationDidFinishLaunching() initRuntime(); #endif - if (!ConfigParser::getInstance()->isInit()) { - ConfigParser::getInstance()->readConfig(); - } - // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); @@ -57,10 +53,6 @@ bool AppDelegate::applicationDidFinishLaunching() director->setOpenGLView(glview); #endif } - - - // set FPS. the default value is 1.0/60 if you don't call this - director->setAnimationInterval(1.0 / 60); auto engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); @@ -98,4 +90,3 @@ void AppDelegate::applicationWillEnterForeground() SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); } - diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.h b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.h index 1b1a9adc09..a2699dc754 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.h +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.h @@ -1,7 +1,8 @@ #ifndef __APP_DELEGATE_H__ #define __APP_DELEGATE_H__ -#include "CCApplication.h" +#include "cocos2d.h" + /** @brief The cocos2d Application. diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp index ac8601941d..d573413cfa 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp @@ -12,18 +12,13 @@ ConfigParser *ConfigParser::getInstance(void) if (!s_sharedInstance) { s_sharedInstance = new ConfigParser(); + s_sharedInstance->readConfig(); } return s_sharedInstance; } -bool ConfigParser::isInit() -{ - return _isInit; -} - void ConfigParser::readConfig() { - _isInit = true; _isWindowTop = false; _consolePort = 6010; _uploadPort = 6020; @@ -107,7 +102,7 @@ void ConfigParser::readConfig() } -ConfigParser::ConfigParser(void):_isInit(false),_isLandscape(true) +ConfigParser::ConfigParser(void):_isLandscape(true) { _initViewSize.setSize(960,640); _viewName = "HelloLua"; diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h b/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h index a4ad886e8f..165fcaccbd 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h @@ -40,7 +40,6 @@ public: int getUploadPort(); bool isLanscape(); bool isWindowTop(); - bool isInit(); private: ConfigParser(void); @@ -50,7 +49,6 @@ private: string _viewName; string _entryfile; bool _isLandscape; - bool _isInit; bool _isWindowTop; int _consolePort; int _uploadPort; diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h b/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h index 8bdd9dee74..f6945cd797 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h @@ -1,27 +1,30 @@ #ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ #define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ -#include "network/lua_cocos2dx_network_manual.h" #include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h" +#include "network/lua_cocos2dx_network_manual.h" #include "cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h" #include "cocostudio/lua_cocos2dx_coco_studio_manual.hpp" #include "extension/lua_cocos2dx_extension_manual.h" #include "ui/lua_cocos2dx_ui_manual.hpp" #include "spine/lua_cocos2dx_spine_manual.hpp" #include "3d/lua_cocos2dx_3d_manual.h" - +#include "audioengine/lua_cocos2dx_audioengine_manual.h" int lua_module_register(lua_State* L) { //Dont' change the module register order unless you know what your are doing - register_network_module(L); register_cocosdenshion_module(L); + register_network_module(L); register_cocosbuilder_module(L); register_cocostudio_module(L); register_ui_moudle(L); register_extension_module(L); register_spine_module(L); register_cocos3d_module(L); +#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS + register_audioengine_module(L); +#endif return 1; } diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index d387e03544..b3aae4624b 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -1160,10 +1160,7 @@ bool initRuntime() LuaStack* stack = engine->getLuaStack(); register_runtime_override_function(stack->getLuaState()); luaopen_debugger(engine->getLuaStack()->getLuaState()); - - if (!ConfigParser::getInstance()->isInit()) { - ConfigParser::getInstance()->readConfig(); - } + static ConsoleCustomCommand *g_customCommand; g_customCommand = new ConsoleCustomCommand(); g_customCommand->init(); diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/build-cfg.json b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/build-cfg.json index 4de0e4d168..9b557cd7ab 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/build-cfg.json +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/build-cfg.json @@ -8,17 +8,11 @@ "copy_resources": [ { "from": "../../../src", - "to": "src", - "exclude": [ - "*.gz" - ] + "to": "src" }, { "from": "../../../res", - "to": "res", - "exclude": [ - "*.gz" - ] + "to": "res" } ], "must_copy_resources": [ diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk index 709c81abae..5a34899872 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk @@ -6,7 +6,8 @@ LOCAL_MODULE := cocos2dlua_shared LOCAL_MODULE_FILENAME := libcocos2dlua -LOCAL_SRC_FILES := \ +LOCAL_SRC_FILES := hellolua/main.cpp \ +hellolua/Runtime_android.cpp \ ../../Classes/protobuf-lite/google/protobuf/io/coded_stream.cc \ ../../Classes/protobuf-lite/google/protobuf/stubs/common.cc \ ../../Classes/protobuf-lite/google/protobuf/extension_set.cc \ @@ -29,9 +30,7 @@ LOCAL_SRC_FILES := \ ../../Classes/runtime/lua_debugger.c \ ../../Classes/VisibleRect.cpp \ ../../Classes/AppDelegate.cpp \ -../../Classes/ConfigParser.cpp \ -lua/Runtime_android.cpp \ -lua/main.cpp +../../Classes/ConfigParser.cpp LOCAL_C_INCLUDES := \ @@ -45,4 +44,3 @@ LOCAL_STATIC_LIBRARIES := cocos2d_lua_static include $(BUILD_SHARED_LIBRARY) $(call import-module,scripting/lua-bindings/proj.android) - diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/Runtime_android.cpp b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/Runtime_android.cpp similarity index 57% rename from templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/Runtime_android.cpp rename to templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/Runtime_android.cpp index 4ef5a738bf..416eb337a1 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/Runtime_android.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/Runtime_android.cpp @@ -6,21 +6,6 @@ using namespace std; using namespace cocos2d; -string getSDCardPath() -{ - JniMethodInfo t; - string sdcardPath(""); - - if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lua/AppActivity", "getSDCardPath", "()Ljava/lang/String;")) { - jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); - t.env->DeleteLocalRef(t.classID); - sdcardPath = JniHelper::jstring2string(str); - t.env->DeleteLocalRef(str); - } - return sdcardPath; - -} - string getIPAddress() { JniMethodInfo t; diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/main.cpp b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp similarity index 88% rename from templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/main.cpp rename to templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp index 87ff60db09..2122669df2 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/lua/main.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp @@ -19,10 +19,6 @@ extern "C" { bool Java_org_cocos2dx_lua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz) { - if (!ConfigParser::getInstance()->isInit()) - { - ConfigParser::getInstance()->readConfig(); - } return ConfigParser::getInstance()->isLanscape(); } diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java index 94d6713256..704c69af9d 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java @@ -45,22 +45,18 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; -import android.os.Environment; import android.provider.Settings; import android.text.format.Formatter; import android.util.Log; import android.view.WindowManager; import android.widget.Toast; -// The name of .so is specified in AndroidMenifest.xml. NativityActivity will load it automatically for you. -// You can use "System.loadLibrary()" to load other .so files. public class AppActivity extends Cocos2dxActivity{ static String hostIPAdress="0.0.0.0"; @Override protected void onCreate(Bundle savedInstanceState) { - // TODO Auto-generated method stub super.onCreate(savedInstanceState); if(nativeIsLandScape()) { @@ -128,14 +124,6 @@ public class AppActivity extends Cocos2dxActivity{ return hostIPAdress; } - public static String getSDCardPath() { - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - String strSDCardPathString = Environment.getExternalStorageDirectory().getPath(); - return strSDCardPathString; - } - return null; - } - private static native boolean nativeIsLandScape(); private static native boolean nativeIsDebug(); diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 82e0185bc0..396f92ca30 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -30,7 +30,6 @@ #import "AppDelegate.h" #import "RootViewController.h" #import "platform/ios/CCEAGLView-ios.h" -#include "ConfigParser.h" @implementation AppController @@ -48,9 +47,7 @@ static AppDelegate s_sharedApplication; cocos2d::GLViewImpl::convertAttrs(); // Override point for customization after application launch. - - ConfigParser::getInstance()->readConfig(); - + // Add the view controller's view to the window and display. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm index ce34f8516e..c0d9d3d6da 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm @@ -25,7 +25,7 @@ #import "RootViewController.h" #import "cocos2d.h" -#import "CCEAGLView.h" +#import "platform/ios/CCEAGLView-ios.h" #include "ConfigParser.h" @implementation RootViewController diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/main.cpp b/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/main.cpp index 54e59a2774..d5f2bac0a4 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/main.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.win32/main.cpp @@ -39,7 +39,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - int ret = Application::getInstance()->run(); #ifdef USE_WIN32_CONSOLE diff --git a/templates/lua-template-runtime/src/main.lua b/templates/lua-template-runtime/src/main.lua index 715ebba0ff..1bd792d84e 100644 --- a/templates/lua-template-runtime/src/main.lua +++ b/templates/lua-template-runtime/src/main.lua @@ -21,6 +21,15 @@ local function main() -- avoid memory leak collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) + + -- initialize director + local director = cc.Director:getInstance() + + --turn on display FPS + director:setDisplayStats(true) + + --set FPS. the default value is 1.0/60 if you don't call this + director:setAnimationInterval(1.0 / 60) cc.FileUtils:getInstance():addSearchPath("src") cc.FileUtils:getInstance():addSearchPath("res")