diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id
index 519851ffa9..99cb9b0f5e 100644
--- a/CHANGELOG.REMOVED.git-id
+++ b/CHANGELOG.REMOVED.git-id
@@ -1 +1 @@
-0b50d2b1b4ed3b031417b663cca76662bdf97fc8
\ No newline at end of file
+874372f8d3779318a2f70b74984575e632ff0dc8
\ No newline at end of file
diff --git a/README.md b/README.md
index 862ef12264..5562ebd9f7 100644
--- a/README.md
+++ b/README.md
@@ -31,42 +31,41 @@ Example:
     $ cd cocos2d-x
     $ ./setup.py
     $ source FILE_TO_SAVE_SYSTEM_VARIABLE
-    $ cocos new mygame -p com.your_company.mygame -l cpp -d /home/mygame
-    $ cd /home/mygame
+    $ cocos new MyGame -p com.your_company.mygame -l cpp -d /home
+    $ cd /home/MyGame
 
-### Build new project for android ###
+### Build and run new project for android ###
 
-    $ cd proj.android
-    $ ./build_native.py
+    $ cocos run -p -j 4 android
 
-### Build new project for ios & osx ###
+### Build and run new project for iOS ###
 
-* Enter *proj.ios_mac* folder, open *mygame.xcodeproj*
-* Select ios or osx targets in scheme toolbar
+    $ cocos run -p ios
+    
+### Build and run new project for OSX ###
 
-### Build new project for linux ###
+    $ cocos run -p mac
+
+### Build and run new project for linux ###
 
 if you never run cocos2d-x on linux, you need to install all dependences by the
 script in **cocos2d/build/install-deps-linux.sh**
 
-    $ cd cocos2d/build
+    $ cd cocos2d-x/build
     $ ./install-deps-linux.sh
-    $ ../..
 
 Then
 
-    $ mkdir build
-    $ cd build
-    $ cmake ..
-    $ make -j4
+    $ cd /home/MyGame
+    $ cocos run -p linux
     
 Run
 
-    $ bin/mygame
+    $ bin/MyGame
 
-### Build new project for win32 ###
+### Build and run new project for win32 ###
 
-* Enter *proj.win32*, open *mygame.sln* by vs2012
+    $ cocos run -p win32
 
 
 Main features
@@ -107,6 +106,7 @@ Build Requirements
 * Mac OS X 10.7+, Xcode 4.6+
 * or Ubuntu 12.10+, CMake 2.6+
 * or Windows 7+, VS 2012+
+* Python 2.7.5
 
 
 Runtime Requirements
@@ -127,7 +127,7 @@ Select the test you want from Xcode Scheme chooser.
 
 ```
 $ cd cocos2d-x/build
-$ open samples.xcodeproj
+$ open cocos_tests.xcodeproj
 ```
 
 * For Linux
@@ -142,9 +142,9 @@ $ make
 Run Samples
 
 ```
-$ bin/hellocpp/hellocpp
+$ bin/cpp-empty-test/cpp-empty-test
 or
-$ bin/testlua/testlua
+$ bin/lua-empty-test/lua-empty-test
 ```
 
       You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target,
@@ -158,10 +158,11 @@ Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln`
 
 ```
 $ cd cocos2d-x/build
-$ python ./android-build.py hellocpp
+$ python ./android-build.py cpp-empty-test -p 10
+$ adb install ../tests/cpp-empty-tst/proj.android/bin/CppEmptyTest-debug.apk
 ```
 
-Import HelloCpp Android project using Eclipse(released with Android SDK). The path to be imported is `cocos2d-x/samples/Cpp/HelloCpp/proj.android`.
+Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10.
 
 
 Contributing to the Project
diff --git a/build/android-build.py b/build/android-build.py
index b2fbc48a3c..1bdf09370a 100755
--- a/build/android-build.py
+++ b/build/android-build.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 # android-build.py
-# Build android 
+# Build android
 
 import sys
 import os, os.path
@@ -12,21 +12,21 @@ LUA_SAMPLES = ['lua-empty-test', 'lua-tests']
 ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
 
 def get_num_of_cpu():
-	''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
-	'''
-	try:
-		platform = sys.platform
-		if platform == 'win32':
-			if 'NUMBER_OF_PROCESSORS' in os.environ:
-				return int(os.environ['NUMBER_OF_PROCESSORS'])
-			else:
-				return 1
-		else:
-			from numpy.distutils import cpuinfo
-			return cpuinfo.cpu._getNCPUs()
-	except Exception:
-		print "Can't know cpuinfo, use default 1 cpu"
-		return 1
+    ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
+    '''
+    try:
+        platform = sys.platform
+        if platform == 'win32':
+            if 'NUMBER_OF_PROCESSORS' in os.environ:
+                return int(os.environ['NUMBER_OF_PROCESSORS'])
+            else:
+                return 1
+        else:
+            from numpy.distutils import cpuinfo
+            return cpuinfo.cpu._getNCPUs()
+    except Exception:
+        print "Can't know cpuinfo, use default 1 cpu"
+        return 1
 
 def check_environment_variables():
     ''' Checking the environment NDK_ROOT, which will be used for building
@@ -39,7 +39,7 @@ def check_environment_variables():
         sys.exit(1)
 
     return NDK_ROOT
-    
+
 def check_environment_variables_sdk():
     ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building
     '''
@@ -74,7 +74,7 @@ def select_toolchain_version():
 def caculate_built_samples(args):
     ''' Compute the sampels to be built
     'cpp' for short of all cpp tests
-    'lua' for short of all lua tests 
+    'lua' for short of all lua tests
     '''
 
     if 'all' in args:
@@ -115,17 +115,17 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an
     if os.system(command) != 0:
         raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
     elif android_platform is not None:
-    	  sdk_tool_path = os.path.join(sdk_root, "tools/android")
-    	  cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java")
-    	  command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) 
-    	  if os.system(command) != 0:
-    	  	  raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")  	  
-    	  command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
-    	  if os.system(command) != 0:
-    	  	  raise Exception("update project [ " + app_android_root + " ] fails!")    	  	  
-    	  buildfile_path = os.path.join(app_android_root, "build.xml")
-    	  command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
-    	  os.system(command)
+        sdk_tool_path = os.path.join(sdk_root, "tools/android")
+        cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java")
+        command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
+        if os.system(command) != 0:
+            raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
+        command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
+        if os.system(command) != 0:
+            raise Exception("update project [ " + app_android_root + " ] fails!")
+        buildfile_path = os.path.join(app_android_root, "build.xml")
+        command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
+        os.system(command)
 
 def copy_files(src, dst):
 
@@ -166,7 +166,7 @@ def copy_resources(target, app_android_root):
         assets_src_dir = os.path.join(assets_dir, "src");
         os.mkdir(assets_src_dir)
         copy_files(resources_dir, assets_src_dir)
-        
+
         resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/lua-bindings/script")
         copy_files(resources_dir, assets_dir)
 
@@ -184,20 +184,20 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
 
     current_dir = os.path.dirname(os.path.realpath(__file__))
     cocos_root = os.path.join(current_dir, "..")
-    
+
     if android_platform is not None:
-		sdk_root = check_environment_variables_sdk()
-		if android_platform.isdigit():
-			android_platform = 'android-'+android_platform
-		else:
-			print 'please use vaild android platform'
-			exit(1)
-    	  
+        sdk_root = check_environment_variables_sdk()
+        if android_platform.isdigit():
+            android_platform = 'android-'+android_platform
+        else:
+            print 'please use vaild android platform'
+            exit(1)
+
     if build_mode is None:
-    	  build_mode = 'debug'
+        build_mode = 'debug'
     elif build_mode != 'release':
         build_mode = 'debug'
-       
+
     app_android_root = ''
 
     target_proj_path_map = {
@@ -214,8 +214,8 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
             print 'unknown target: %s' % target
             continue
 
-    copy_resources(target, app_android_root)
-    do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode)
+        copy_resources(target, app_android_root)
+        do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode)
 
 # -------------- main --------------
 if __name__ == '__main__':
@@ -223,8 +223,8 @@ if __name__ == '__main__':
     #parse the params
     usage = """
     This script is mainy used for building tests built-in with cocos2d-x.
-    
-    Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests]
+
+    Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests|cpp|lua|all]
 
     If you are new to cocos2d-x, I recommend you start with cpp-empty-test, lua-empty-test.
 
@@ -237,16 +237,17 @@ if __name__ == '__main__':
     """
 
     parser = OptionParser(usage=usage)
-    parser.add_option("-n", "--ndk", dest="ndk_build_param", 
+    parser.add_option("-n", "--ndk", dest="ndk_build_param",
     help='Parameter for ndk-build')
-    parser.add_option("-p", "--platform", dest="android_platform", 
+    parser.add_option("-p", "--platform", dest="android_platform",
     help='Parameter for android-update. Without the parameter,the script just build dynamic library for the projects. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]')
-    parser.add_option("-b", "--build", dest="build_mode", 
+    parser.add_option("-b", "--build", dest="build_mode",
     help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
     (opts, args) = parser.parse_args()
 
     if len(args) == 0:
         parser.print_help()
+        sys.exit(1)
     else:
         try:
             build_samples(args, opts.ndk_build_param,opts.android_platform,opts.build_mode)
diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id
index 8088b36f0b..df0f90e563 100644
--- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id
+++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id
@@ -1 +1 @@
-bbf0323293cba3d7ee58ef36706831a8761692d8
\ No newline at end of file
+b8986c04c89d3861f82fb99b0df633ac2cc4a13c
\ No newline at end of file
diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id
index e6f0599f23..e4fd4a2b00 100644
--- a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id
+++ b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id
@@ -1 +1 @@
-66526d30a3e76bb1b54c7615a18c467845798e78
\ No newline at end of file
+2c5a07d179e9514618036dfb7cfedd3f9cf4c506
\ No newline at end of file
diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp
index e1fc7ad829..a0cf4c2070 100644
--- a/cocos/2d/CCFontAtlas.cpp
+++ b/cocos/2d/CCFontAtlas.cpp
@@ -27,16 +27,22 @@
 #include "CCFontFreeType.h"
 #include "ccUTF8.h"
 #include "CCDirector.h"
+#include "CCEventListenerCustom.h"
+#include "CCEventDispatcher.h"
+#include "CCEventType.h"
 
 NS_CC_BEGIN
 
 const int FontAtlas::CacheTextureWidth = 1024;
 const int FontAtlas::CacheTextureHeight = 1024;
+const char* FontAtlas::EVENT_PURGE_TEXTURES = "__cc_FontAtlasPurgeTextures";
 
 FontAtlas::FontAtlas(Font &theFont) 
 : _font(&theFont)
 , _currentPageData(nullptr)
 , _fontAscender(0)
+, _toForegroundListener(nullptr)
+, _toBackgroundListener(nullptr)
 {
     _font->retain();
 
@@ -61,15 +67,40 @@ FontAtlas::FontAtlas(Font &theFont)
             _currentPageDataSize *= 2;
         }    
 
-        _currentPageData = new unsigned char[_currentPageDataSize];       
+        _currentPageData = new unsigned char[_currentPageDataSize];
         memset(_currentPageData, 0, _currentPageDataSize);  
         addTexture(texture,0);
         texture->release();
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+        auto eventDispatcher = Director::getInstance()->getEventDispatcher();
+        _toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(FontAtlas::listenToBackground, this));
+        eventDispatcher->addEventListenerWithFixedPriority(_toBackgroundListener, 1);
+        _toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(FontAtlas::listenToForeground, this));
+        eventDispatcher->addEventListenerWithFixedPriority(_toForegroundListener, 1);
+#endif
     }
 }
 
 FontAtlas::~FontAtlas()
 {
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+    FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
+    if (fontTTf)
+    {
+        auto eventDispatcher = Director::getInstance()->getEventDispatcher();
+        if (_toForegroundListener)
+        {
+            eventDispatcher->removeEventListener(_toForegroundListener);
+            _toForegroundListener = nullptr;
+        }
+        if (_toBackgroundListener)
+        {
+            eventDispatcher->removeEventListener(_toBackgroundListener);
+            _toBackgroundListener = nullptr;
+        }
+    }
+#endif
+
     _font->release();
     relaseTextures();
 
@@ -82,6 +113,82 @@ void FontAtlas::relaseTextures()
     {
         item.second->release();
     }
+    _atlasTextures.clear();
+}
+
+void FontAtlas::purgeTexturesAtlas()
+{
+    FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
+    if (fontTTf && _atlasTextures.size() > 1)
+    {
+        for( auto &item: _atlasTextures)
+        {
+            if (item.first != 0)
+            {
+                item.second->release();
+            }
+        }
+        auto temp = _atlasTextures[0];
+        _atlasTextures.clear();
+        _atlasTextures[0] = temp;
+
+        _fontLetterDefinitions.clear();
+        memset(_currentPageData,0,_currentPageDataSize);
+        _currentPage = 0;
+        _currentPageOrigX = 0;
+        _currentPageOrigY = 0;
+
+        auto eventDispatcher = Director::getInstance()->getEventDispatcher();
+        eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
+    }
+}
+
+void FontAtlas::listenToBackground(EventCustom *event)
+{
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+    FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
+    if (fontTTf && _atlasTextures.size() > 1)
+    {
+        for( auto &item: _atlasTextures)
+        {
+            if (item.first != 0)
+            {
+                item.second->release();
+            }
+        }
+        auto temp = _atlasTextures[0];
+        _atlasTextures.clear();
+        _atlasTextures[0] = temp;
+
+        _fontLetterDefinitions.clear();
+        memset(_currentPageData,0,_currentPageDataSize);
+        _currentPage = 0;
+        _currentPageOrigX = 0;
+        _currentPageOrigY = 0;
+    }
+#endif
+}
+
+void FontAtlas::listenToForeground(EventCustom *event)
+{
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+    FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
+    if (fontTTf)
+    {
+        if (_currentPageOrigX == 0 && _currentPageOrigY == 0)
+        {
+            auto eventDispatcher = Director::getInstance()->getEventDispatcher();
+            eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
+        }
+        else
+        {
+            auto contentSize = Size(CacheTextureWidth,CacheTextureHeight);
+            auto  pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
+
+            _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
+        }
+    }
+#endif
 }
 
 void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition)
@@ -107,10 +214,10 @@ bool FontAtlas::getLetterDefinitionForChar(unsigned short  letteCharUTF16, FontL
 
 bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
 {
-    if(_currentPageData == nullptr)
+    FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
+    if(fontTTf == nullptr)
         return false;
 
-    FontFreeType* fontTTf = (FontFreeType*)_font;
     int length = cc_wcslen(utf16String);
 
     float offsetAdjust = _letterPadding / 2;  
@@ -150,11 +257,6 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
                     {             
                         _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
                         _currentPageOrigY = 0;
-
-                        delete []_currentPageData;
-                        _currentPageData = new unsigned char[_currentPageDataSize];
-                        if(_currentPageData == nullptr)
-                            return false;
                         memset(_currentPageData, 0, _currentPageDataSize);
                         _currentPage++;
                         auto tex = new Texture2D;
diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h
index 31a2110e4c..9059e119c9 100644
--- a/cocos/2d/CCFontAtlas.h
+++ b/cocos/2d/CCFontAtlas.h
@@ -34,6 +34,8 @@ NS_CC_BEGIN
 //fwd
 class Font;
 class Texture2D;
+class EventCustom;
+class EventListenerCustom;
 
 struct FontLetterDefinition
 {
@@ -54,6 +56,7 @@ class CC_DLL FontAtlas : public Ref
 public:
     static const int CacheTextureWidth;
     static const int CacheTextureHeight;
+    static const char* EVENT_PURGE_TEXTURES;
     /**
      * @js ctor
      */
@@ -76,7 +79,22 @@ public:
     
     Texture2D* getTexture(int slot);
     const Font* getFont() const;
+
+    /** Listen "come to background" message, and clear the texture atlas.
+     It only has effect on Android.
+     */
+    void listenToBackground(EventCustom *event);
+
+    /** Listen "come to foreground" message and restore the texture atlas.
+     It only has effect on Android.
+     */
+    void listenToForeground(EventCustom *event);
     
+    /** Removes textures atlas.
+     It will purge the textures atlas and if multiple texture exist in the FontAtlas.
+     */
+    void purgeTexturesAtlas();
+
 private:
 
     void relaseTextures();
@@ -95,6 +113,8 @@ private:
     bool  _makeDistanceMap;
 
     int _fontAscender;
+    EventListenerCustom* _toBackgroundListener;
+    EventListenerCustom* _toForegroundListener;
 };
 
 
diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp
index 60494a0222..119332d009 100644
--- a/cocos/2d/CCFontAtlasCache.cpp
+++ b/cocos/2d/CCFontAtlasCache.cpp
@@ -36,6 +36,14 @@ NS_CC_BEGIN
 
 std::unordered_map<std::string, FontAtlas *> FontAtlasCache::_atlasMap;
 
+void FontAtlasCache::purgeCachedData()
+{
+    for (auto & atlas:_atlasMap)
+    {
+        atlas.second->purgeTexturesAtlas();
+    }
+}
+
 FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
 {  
     bool useDistanceField = config.distanceFieldEnabled;
@@ -46,7 +54,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
     int fontSize = config.fontSize;
     if (useDistanceField)
     {
-        fontSize = Label::DistanceFieldFontSize;
+        fontSize = Label::DistanceFieldFontSize / CC_CONTENT_SCALE_FACTOR();
     }
 
     std::string atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField);
diff --git a/cocos/2d/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h
index 1806ff83f8..18c1e88b6c 100644
--- a/cocos/2d/CCFontAtlasCache.h
+++ b/cocos/2d/CCFontAtlasCache.h
@@ -45,6 +45,11 @@ public:
     static FontAtlas * getFontAtlasCharMap(const std::string& plistFile);
     
     static bool releaseFontAtlas(FontAtlas *atlas);
+
+    /** Removes cached data.
+     It will purge the textures atlas and if multiple texture exist in one FontAtlas.
+     */
+    static void purgeCachedData();
     
 private: 
     static std::string generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField);
diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp
index 3cede4756a..448dc2c0b1 100644
--- a/cocos/2d/CCLabel.cpp
+++ b/cocos/2d/CCLabel.cpp
@@ -33,6 +33,10 @@
 #include "CCDirector.h"
 #include "renderer/CCRenderer.h"
 #include "CCFont.h"
+#include "CCEventListenerCustom.h"
+#include "CCEventDispatcher.h"
+#include "CCEventType.h"
+#include "CCEventCustom.h"
 
 NS_CC_BEGIN
 
@@ -278,6 +282,14 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
     _cascadeColorEnabled = true;
     
     reset();
+
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+    auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(Label::listenToBackground, this));
+    _eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this);
+#endif
+
+    auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, CC_CALLBACK_1(Label::listenToFontAtlasPurge, this));
+    _eventDispatcher->addEventListenerWithSceneGraphPriority(purgeTextureListener, this);
 }
 
 Label::~Label()
@@ -404,6 +416,8 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
         return false;
     }
 
+    setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
+
     _fontConfig = ttfConfig;
     if (_fontConfig.outlineSize > 0)
     {
@@ -418,8 +432,6 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
         this->setFontScale(1.0f * ttfConfig.fontSize / DistanceFieldFontSize);
     }
 
-    setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
-
     _currentLabelType = LabelType::TTF;
 
     return true;
@@ -813,7 +825,7 @@ void Label::disableEffect()
 
 void Label::setFontScale(float fontScale)
 {
-    _fontScale = fontScale;
+    _fontScale = fontScale * CC_CONTENT_SCALE_FACTOR();
     Node::setScale(_fontScale);
 }
 
@@ -1024,13 +1036,7 @@ void Label::setFontName(const std::string& fontName)
 
 const std::string& Label::getFontName() const
 {
-    switch (_currentLabelType)
-    {
-    case LabelType::TTF:
-        return _fontConfig.fontFilePath;
-    default:
-        return _fontDefinition._fontName;
-    }
+    return _fontName;
 }
 
 void Label::setFontSize(int fontSize)
@@ -1044,15 +1050,7 @@ void Label::setFontSize(int fontSize)
 
 int Label::getFontSize() const
 {
-    switch (_currentLabelType)
-    {
-    case LabelType::TTF:
-        return _fontConfig.fontSize;
-    case LabelType::STRING_TEXTURE:
-        return _fontDefinition._fontSize;
-    default:
-        return 0;
-    }
+    return _fontSize;
 }
 
 ///// PROTOCOL STUFF
@@ -1215,4 +1213,24 @@ const Size& Label::getContentSize() const
     return Node::getContentSize();
 }
 
+void Label::listenToBackground(EventCustom *event)
+{
+#if CC_ENABLE_CACHE_TEXTURE_DATA
+    if (_fontAtlas && _currentLabelType == LabelType::TTF)
+    {
+        _batchNodes.clear();
+        _batchNodes.push_back(this);
+        Node::removeAllChildrenWithCleanup(true);
+    }
+#endif
+}
+
+void Label::listenToFontAtlasPurge(EventCustom *event)
+{
+    if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
+    {
+        alignText();
+    }
+}
+
 NS_CC_END
diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h
index 89f7252d43..bef78167a6 100644
--- a/cocos/2d/CCLabel.h
+++ b/cocos/2d/CCLabel.h
@@ -230,6 +230,15 @@ public:
 
     virtual const Size& getContentSize() const override;
 
+    /** Listen "come to background" message
+     It only has effect on Android.
+     */
+    void listenToBackground(EventCustom *event);
+
+    /** Listen "FontAtlas purge textures" message
+     */
+    void listenToFontAtlasPurge(EventCustom *event);
+
 protected:
     void onDraw(const kmMat4& transform, bool transformUpdated);
 
diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp
index 84c889d81f..1917ea4537 100644
--- a/cocos/2d/CCLabelAtlas.cpp
+++ b/cocos/2d/CCLabelAtlas.cpp
@@ -226,6 +226,24 @@ const std::string& LabelAtlas::getString(void) const
     return _string;
 }
 
+void LabelAtlas::updateColor()
+{
+    if (_textureAtlas)
+    {
+        Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
+        auto quads = _textureAtlas->getQuads();
+        ssize_t length = _string.length();
+        for (int index = 0; index < length; index++)
+        {
+            quads[index].bl.colors = color4;
+            quads[index].br.colors = color4;
+            quads[index].tl.colors = color4;
+            quads[index].tr.colors = color4;
+            _textureAtlas->updateQuad(&quads[index], index);
+        }
+    }
+}
+
 //CCLabelAtlas - draw
 
 #if CC_LABELATLAS_DEBUG_DRAW    
diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h
index 47064c14c7..157a897c88 100644
--- a/cocos/2d/CCLabelAtlas.h
+++ b/cocos/2d/CCLabelAtlas.h
@@ -94,7 +94,8 @@ protected:
     {
         _string.clear();
     }
-    
+    virtual void updateColor() override;
+
     // string to render
     std::string _string;
     // the first char in the charmap
diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp
index 38645d960f..cfcee2e726 100644
--- a/cocos/2d/CCMenuItem.cpp
+++ b/cocos/2d/CCMenuItem.cpp
@@ -29,7 +29,7 @@ THE SOFTWARE.
 #include "CCActionInterval.h"
 #include "CCSprite.h"
 #include "CCLabelAtlas.h"
-#include "CCLabelTTF.h"
+#include "CCLabel.h"
 #include "CCScriptSupport.h"
 #include <stdarg.h>
 #include <cstring>
@@ -301,12 +301,12 @@ void MenuItemLabel::setEnabled(bool enabled)
     {
         if(enabled == false)
         {
-            _colorBackup = _label->getColor();
-            _label->setColor(_disabledColor);
+            _colorBackup = this->getColor();
+            this->setColor(_disabledColor);
         }
         else
         {
-            _label->setColor(_colorBackup);
+            this->setColor(_colorBackup);
         }
     }
     MenuItem::setEnabled(enabled);
@@ -439,7 +439,7 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback
     _fontName = _globalFontName;
     _fontSize = _globalFontSize;
 
-    LabelTTF *label = LabelTTF::create(value, _fontName, (float)_fontSize);
+    Label *label = Label::create(value, _fontName, _fontSize);
     if (MenuItemLabel::initWithLabel(label, callback))
     {
         // do something ?
@@ -447,17 +447,11 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback
     return true;
 }
 
-void MenuItemFont::recreateLabel()
-{
-    LabelTTF *label = LabelTTF::create(dynamic_cast<LabelProtocol*>(_label)->getString(), 
-                                                    _fontName.c_str(), (float)_fontSize);
-    this->setLabel(label);
-}
-
 void MenuItemFont::setFontSizeObj(int s)
 {
     _fontSize = s;
-    recreateLabel();
+    dynamic_cast<Label*>(_label)->setFontSize(_fontSize);
+    this->setContentSize(dynamic_cast<Label*>(_label)->getContentSize());
 }
 
 int MenuItemFont::getFontSizeObj() const
@@ -468,7 +462,8 @@ int MenuItemFont::getFontSizeObj() const
 void MenuItemFont::setFontNameObj(const std::string& name)
 {
     _fontName = name;
-    recreateLabel();
+    dynamic_cast<Label*>(_label)->setFontName(_fontName);
+    this->setContentSize(dynamic_cast<Label*>(_label)->getContentSize());
 }
 
 const std::string& MenuItemFont::getFontNameObj() const
diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h
index 263c0bec7c..2e28f52037 100644
--- a/cocos/2d/CCMenuItem.h
+++ b/cocos/2d/CCMenuItem.h
@@ -40,7 +40,7 @@ NS_CC_BEGIN
 
 typedef std::function<void(Ref*)> ccMenuCallback;
 
-class LabelTTF;
+class Label;
 class LabelAtlas;
 class Sprite;
 class SpriteFrame;
@@ -142,6 +142,7 @@ private:
  - BitmapFontAtlas
  - LabelAtlas
  - LabelTTF
+ - Label
  */
 class CC_DLL MenuItemLabel : public MenuItem
 {
@@ -310,8 +311,6 @@ protected:
     CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Ref* target, SEL_MenuHandler selector);
     /** initializes a menu item from a string with a target/selector */
     bool initWithString(const std::string& value, const ccMenuCallback& callback);
-
-    void recreateLabel();
     
     int _fontSize;
     std::string _fontName;
diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp
index 00d19415f2..1007dd9585 100644
--- a/cocos/2d/CCTMXLayer.cpp
+++ b/cocos/2d/CCTMXLayer.cpp
@@ -224,7 +224,7 @@ void TMXLayer::parseInternalProperties()
 void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, int gid)
 {
     sprite->setPosition(getPositionAt(pos));
-    sprite->setVertexZ((float)getVertexZForPos(pos));
+    sprite->setPositionZ((float)getVertexZForPos(pos));
     sprite->setAnchorPoint(Point::ZERO);
     sprite->setOpacity(_opacity);
 
@@ -326,7 +326,7 @@ Sprite * TMXLayer::getTileAt(const Point& pos)
             tile = Sprite::createWithTexture(this->getTexture(), rect);
             tile->setBatchNode(this);
             tile->setPosition(getPositionAt(pos));
-            tile->setVertexZ((float)getVertexZForPos(pos));
+            tile->setPositionZ((float)getVertexZForPos(pos));
             tile->setAnchorPoint(Point::ZERO);
             tile->setOpacity(_opacity);
 
diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp
index 3a558106c3..0e7bd4f647 100644
--- a/cocos/2d/CCTextureCache.cpp
+++ b/cocos/2d/CCTextureCache.cpp
@@ -500,11 +500,9 @@ void TextureCache::waitForQuit()
 
 std::string TextureCache::getCachedTextureInfo() const
 {
-    char buffer[16386];
+    std::string buffer;
     char buftmp[4096];
 
-    memset(buffer,0,sizeof(buffer));
-
     unsigned int count = 0;
     unsigned int totalBytes = 0;
 
@@ -527,13 +525,14 @@ std::string TextureCache::getCachedTextureInfo() const
                (long)tex->getPixelsHigh(),
                (long)bpp,
                (long)bytes / 1024);
-        strcat(buffer, buftmp);
+        
+        buffer += buftmp;
     }
 
     snprintf(buftmp, sizeof(buftmp)-1, "TextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)\n", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f));
-    strcat(buffer, buftmp);
+    buffer += buftmp;
 
-    return std::string(buffer);
+    return buffer;
 }
 
 #if CC_ENABLE_CACHE_TEXTURE_DATA
diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj
index f0855c3101..b491f0fd9d 100644
--- a/cocos/2d/cocos2d.vcxproj
+++ b/cocos/2d/cocos2d.vcxproj
@@ -84,6 +84,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
+      <CompileAs>CompileAsCpp</CompileAs>
     </ClCompile>
     <PreLinkEvent>
       <Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
@@ -129,6 +130,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
+      <CompileAs>CompileAsCpp</CompileAs>
     </ClCompile>
     <PreLinkEvent>
       <Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
@@ -182,42 +184,20 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
     <ClCompile Include="..\base\CCValue.cpp" />
     <ClCompile Include="..\base\etc1.cpp" />
     <ClCompile Include="..\base\s3tc.cpp" />
-    <ClCompile Include="..\math\kazmath\kazmath\aabb.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
+    <ClCompile Include="..\math\kazmath\kazmath\aabb.c" />
     <ClCompile Include="..\math\kazmath\kazmath\GL\mat4stack.c" />
     <ClCompile Include="..\math\kazmath\kazmath\GL\matrix.c" />
-    <ClCompile Include="..\math\kazmath\kazmath\mat3.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\mat4.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
+    <ClCompile Include="..\math\kazmath\kazmath\mat3.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\mat4.c" />
     <ClCompile Include="..\math\kazmath\kazmath\neon_matrix_impl.c" />
-    <ClCompile Include="..\math\kazmath\kazmath\plane.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\quaternion.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\ray2.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\ray3.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\utility.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\vec2.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\vec3.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
-    <ClCompile Include="..\math\kazmath\kazmath\vec4.c">
-      <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
-    </ClCompile>
+    <ClCompile Include="..\math\kazmath\kazmath\plane.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\quaternion.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\ray2.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\ray3.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\utility.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\vec2.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\vec3.c" />
+    <ClCompile Include="..\math\kazmath\kazmath\vec4.c" />
     <ClCompile Include="..\physics\CCPhysicsBody.cpp" />
     <ClCompile Include="..\physics\CCPhysicsContact.cpp" />
     <ClCompile Include="..\physics\CCPhysicsJoint.cpp" />
@@ -558,6 +538,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
     <ClInclude Include="utlist.h" />
     <ClInclude Include="ZipUtils.h" />
   </ItemGroup>
+  <ItemGroup>
+    <Text Include="..\math\kazmath\kazmath\CMakeLists.txt" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters
index 93a4983b67..c363dfc54b 100644
--- a/cocos/2d/cocos2d.vcxproj.filters
+++ b/cocos/2d/cocos2d.vcxproj.filters
@@ -91,21 +91,6 @@
     <Filter Include="physics\chipmunk">
       <UniqueIdentifier>{aeadfa95-9c89-4212-98ae-89ad57db596a}</UniqueIdentifier>
     </Filter>
-    <Filter Include="kazmath\include">
-      <UniqueIdentifier>{05e27e68-7574-4a8b-af68-553dd3bafdfa}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="kazmath\src">
-      <UniqueIdentifier>{b797075f-7437-46d5-b4ee-2aa2c108e98f}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="kazmath\src\GL">
-      <UniqueIdentifier>{c755509d-1610-4e6c-b01b-e01d4d0de46e}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="kazmath\include\kazmath">
-      <UniqueIdentifier>{e1b64497-c099-4f06-8d61-9d4c6b7a215a}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="kazmath\include\kazmath\GL">
-      <UniqueIdentifier>{7c71abeb-8b4b-4be8-a23c-e32fedc65fc9}</UniqueIdentifier>
-    </Filter>
     <Filter Include="base">
       <UniqueIdentifier>{aec8225f-81a7-4213-b97b-7004d5535398}</UniqueIdentifier>
     </Filter>
@@ -115,6 +100,9 @@
     <Filter Include="platform\desktop">
       <UniqueIdentifier>{32373f63-2c2d-4eab-bc4a-21745ba0b3fb}</UniqueIdentifier>
     </Filter>
+    <Filter Include="kazmath\GL">
+      <UniqueIdentifier>{465965df-dc31-471a-887f-e430125b8ba0}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\physics\CCPhysicsBody.cpp">
@@ -561,46 +549,46 @@
     </ClCompile>
     <ClCompile Include="CCTweenFunction.cpp" />
     <ClCompile Include="..\math\kazmath\kazmath\GL\mat4stack.c">
-      <Filter>kazmath\src\GL</Filter>
+      <Filter>kazmath\GL</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\GL\matrix.c">
-      <Filter>kazmath\src\GL</Filter>
+      <Filter>kazmath\GL</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\aabb.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\mat3.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\mat4.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\neon_matrix_impl.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\plane.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\quaternion.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\ray2.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\ray3.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\utility.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\vec2.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\vec3.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
     <ClCompile Include="..\math\kazmath\kazmath\vec4.c">
-      <Filter>kazmath\src</Filter>
+      <Filter>kazmath</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
@@ -1162,49 +1150,54 @@
     </ClInclude>
     <ClInclude Include="CCTweenFunction.h" />
     <ClInclude Include="..\math\kazmath\kazmath\GL\mat4stack.h">
-      <Filter>kazmath\include\kazmath\GL</Filter>
+      <Filter>kazmath\GL</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\GL\matrix.h">
-      <Filter>kazmath\include\kazmath\GL</Filter>
+      <Filter>kazmath\GL</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\aabb.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\kazmath.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\mat3.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\mat4.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\neon_matrix_impl.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\plane.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\quaternion.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\ray2.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\ray3.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\utility.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\vec2.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\vec3.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
     <ClInclude Include="..\math\kazmath\kazmath\vec4.h">
-      <Filter>kazmath\include\kazmath</Filter>
+      <Filter>kazmath</Filter>
     </ClInclude>
   </ItemGroup>
+  <ItemGroup>
+    <Text Include="..\math\kazmath\kazmath\CMakeLists.txt">
+      <Filter>kazmath</Filter>
+    </Text>
+  </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/cocos/2d/platform/desktop/CCGLView.cpp b/cocos/2d/platform/desktop/CCGLView.cpp
index 0b4dcc7e11..9c2d4a390d 100644
--- a/cocos/2d/platform/desktop/CCGLView.cpp
+++ b/cocos/2d/platform/desktop/CCGLView.cpp
@@ -399,7 +399,7 @@ void GLView::swapBuffers()
 bool GLView::windowShouldClose()
 {
     if(_mainWindow)
-        return glfwWindowShouldClose(_mainWindow);
+        return glfwWindowShouldClose(_mainWindow) ? true : false;
     else
         return true;
 }
diff --git a/cocos/2d/platform/linux/CCApplication.cpp b/cocos/2d/platform/linux/CCApplication.cpp
index 9d8e81fb1d..9ea95ec06f 100644
--- a/cocos/2d/platform/linux/CCApplication.cpp
+++ b/cocos/2d/platform/linux/CCApplication.cpp
@@ -70,17 +70,26 @@ int Application::run()
         return 0;
     }
 
+    long lastTime = 0L;
+    long curTime = 0L;
+
     auto director = Director::getInstance();
     auto glview = director->getOpenGLView();
 
+    // Retain glview to avoid glview being released in the while loop
+    glview->retain();
+
     while (!glview->windowShouldClose())
     {
-        long iLastTime = getCurrentMillSecond();
+        lastTime = getCurrentMillSecond();
+
         director->mainLoop();
         glview->pollEvents();
-        long iCurTime = getCurrentMillSecond();
-        if (iCurTime-iLastTime<_animationInterval){
-            usleep((_animationInterval - iCurTime+iLastTime)*1000);
+
+        curTime = getCurrentMillSecond();
+        if (curTime - lastTime < _animationInterval)
+        {
+            usleep((_animationInterval - curTime + lastTime)*1000);
         }
     }
     /* Only work on Desktop
@@ -88,8 +97,13 @@ int Application::run()
     *  when we want to close the window, we should call Director::end();
     *  then call Director::mainLoop to do release of internal resources
     */
-    director->end();
-    director->mainLoop();
+    if (glview->isOpenGLReady())
+    {
+        director->end();
+        director->mainLoop();
+        director = nullptr;
+    }
+    glview->release();
     return -1;
 }
 
diff --git a/cocos/2d/platform/mac/CCApplication.mm b/cocos/2d/platform/mac/CCApplication.mm
index d739404b45..43dd21583a 100644
--- a/cocos/2d/platform/mac/CCApplication.mm
+++ b/cocos/2d/platform/mac/CCApplication.mm
@@ -68,16 +68,27 @@ int Application::run()
     {
         return 0;
     }
-    GLView* glview = Director::getInstance()->getOpenGLView();
+    
+    long lastTime = 0L;
+    long curTime = 0L;
+    
+    auto director = Director::getInstance();
+    auto glview = director->getOpenGLView();
+    
+    // Retain glview to avoid glview being released in the while loop
+    glview->retain();
     
     while (!glview->windowShouldClose())
     {
-        long iLastTime = getCurrentMillSecond();
-        Director::getInstance()->mainLoop();
+        lastTime = getCurrentMillSecond();
+        
+        director->mainLoop();
         glview->pollEvents();
-        long iCurTime = getCurrentMillSecond();
-        if (iCurTime-iLastTime<_animationInterval){
-            usleep(static_cast<useconds_t>((_animationInterval - iCurTime+iLastTime)*1000));
+
+        curTime = getCurrentMillSecond();
+        if (curTime - lastTime < _animationInterval)
+        {
+            usleep(static_cast<useconds_t>((_animationInterval - curTime + lastTime)*1000));
         }
     }
 
@@ -86,8 +97,14 @@ int Application::run()
     *  when we want to close the window, we should call Director::end();
     *  then call Director::mainLoop to do release of internal resources
     */
-    Director::getInstance()->end();
-    Director::getInstance()->mainLoop();
+    if (glview->isOpenGLReady())
+    {
+        director->end();
+        director->mainLoop();
+    }
+    
+    glview->release();
+    
     return true;
 }
 
diff --git a/cocos/2d/platform/win32/CCApplication.cpp b/cocos/2d/platform/win32/CCApplication.cpp
index a0b0b4a25b..05dd5ee4ac 100644
--- a/cocos/2d/platform/win32/CCApplication.cpp
+++ b/cocos/2d/platform/win32/CCApplication.cpp
@@ -79,12 +79,16 @@ int Application::run()
     auto director = Director::getInstance();
     auto glview = director->getOpenGLView();
 
+    // Retain glview to avoid glview being released in the while loop
+    glview->retain();
+
     while(!glview->windowShouldClose())
     {
         QueryPerformanceCounter(&nNow);
         if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart)
         {
             nLast.QuadPart = nNow.QuadPart;
+            
             director->mainLoop();
             glview->pollEvents();
         }
@@ -101,6 +105,7 @@ int Application::run()
         director->mainLoop();
         director = nullptr;
     }
+    glview->release();
     return true;
 }
 
diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp
index 87c44d5d8c..8b93969262 100644
--- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp
+++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp
@@ -110,7 +110,7 @@ bool FileUtilsWin32::isFileExist(const std::string& strFilePath) const
     }
 
     WCHAR utf16Buf[CC_MAX_PATH] = {0};
-    MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf));
+    MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)/sizeof(utf16Buf[0]));
 
     return GetFileAttributesW(utf16Buf) != -1 ? true : false;
 }
@@ -137,7 +137,7 @@ static Data getData(const std::string& filename, bool forString)
         std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename);
 
         WCHAR wszBuf[CC_MAX_PATH] = {0};
-        MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf));
+        MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
 
         HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL);
         CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE);
@@ -211,7 +211,7 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch
         std::string fullPath = fullPathForFilename(filename);
 
         WCHAR wszBuf[CC_MAX_PATH] = {0};
-        MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf));
+        MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
 
         HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL);
         CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE);
diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp
index 40fc8970f6..99b37ae047 100644
--- a/cocos/base/CCConsole.cpp
+++ b/cocos/base/CCConsole.cpp
@@ -214,7 +214,7 @@ static void _log(const char *format, va_list args)
     WCHAR wszBuf[MAX_LOG_LENGTH] = {0};
     MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf));
     OutputDebugStringW(wszBuf);
-    WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), buf, sizeof(buf), NULL, FALSE);
+    WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE);
     printf("%s", buf);
 
 #else
diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp
index e1184f1464..88584c8029 100644
--- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp
+++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp
@@ -488,11 +488,11 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node
             } else if(propName == "rotationX")
             {
                 float rotate = value.asFloat();
-                pNode->setRotationX(rotate);
+                pNode->setRotationSkewX(rotate);
             }else if(propName == "rotationY")
             {
                 float rotate = value.asFloat();
-                pNode->setRotationY(rotate);
+                pNode->setRotationSkewY(rotate);
             }
             else if (propName == "opacity")
             {
@@ -1169,7 +1169,7 @@ void CCBRotateXTo::startWithTarget(Node *pNode)
     _target = pNode;
     _elapsed = 0.0f;
     _firstTick = true;
-    _startAngle = _target->getRotationX();
+    _startAngle = _target->getRotationSkewX();
     _diffAngle = _dstAngle - _startAngle;
 }
 
@@ -1190,8 +1190,7 @@ CCBRotateXTo* CCBRotateXTo::reverse() const
 
 void CCBRotateXTo::update(float time)
 {
-    _target->setRotationX(_startAngle + (_diffAngle * time))
-    ;
+    _target->setRotationSkewX(_startAngle + (_diffAngle * time));
 }
 
 
@@ -1257,14 +1256,13 @@ void CCBRotateYTo::startWithTarget(Node *pNode)
     _target = pNode;
     _elapsed = 0.0f;
     _firstTick = true;
-    _startAngle = _target->getRotationY();
+    _startAngle = _target->getRotationSkewY();
     _diffAngle = _dstAngle - _startAngle;
 }
 
 void CCBRotateYTo::update(float time)
 {
-    _target->setRotationY(_startAngle + (_diffAngle * time))
-    ;
+    _target->setRotationSkewY(_startAngle + (_diffAngle * time));
 }
 
 
diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp
index 2d0bffe22f..80d2676e39 100644
--- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp
+++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp
@@ -79,7 +79,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
                 pNode = ccbNode->getCCBFileNode();
                 
                 // Skip properties that doesn't have a value to override
-                Array *extraPropsNames = (Array*)pNode->getUserObject();
+                __Array *extraPropsNames = (__Array*)pNode->getUserObject();
                 Ref* pObj = NULL;
                 bool bFound = false;
                 CCARRAY_FOREACH(extraPropsNames, pObj)
@@ -1055,9 +1055,9 @@ void NodeLoader::onHandlePropTypeDegrees(Node * pNode, Node * pParent, const cha
     if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) {
         pNode->setRotation(pDegrees);
     } else if(strcmp(pPropertyName, PROPERTY_ROTATIONX) == 0) {
-        pNode->setRotationX(pDegrees);
+        pNode->setRotationSkewX(pDegrees);
     } else if(strcmp(pPropertyName, PROPERTY_ROTATIONY) == 0) {
-        pNode->setRotationY(pDegrees);
+        pNode->setRotationSkewY(pDegrees);
     }
     else {
         ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp
index bf0b311b04..710297c001 100644
--- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp
+++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp
@@ -157,7 +157,7 @@ const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const
     
 void GUIReader::registerTypeAndCallBack(const std::string& classType,
                                         ObjectFactory::Instance ins,
-                                        Object *object,
+                                        Ref *object,
                                         SEL_ParseEvent callBack)
 {
     ObjectFactory* factoryCreate = ObjectFactory::getInstance();
@@ -2030,8 +2030,8 @@ void WidgetPropertiesReader0300::setPropsForAllCustomWidgetFromJsonDictionary(co
 {
     GUIReader* guiReader = GUIReader::getInstance();
     
-    std::map<std::string, Object*> object_map = GUIReader::getInstance()->getParseObjectMap();
-    Object* object = object_map[classType];
+    std::map<std::string, Ref*> object_map = GUIReader::getInstance()->getParseObjectMap();
+    Ref* object = object_map[classType];
     
     std::map<std::string, SEL_ParseEvent> selector_map = guiReader->getParseCallBackMap();
     SEL_ParseEvent selector = selector_map[classType];
diff --git a/cocos/editor-support/cocostudio/ObjectFactory.cpp b/cocos/editor-support/cocostudio/ObjectFactory.cpp
index 87b724b984..26bb4d7c35 100644
--- a/cocos/editor-support/cocostudio/ObjectFactory.cpp
+++ b/cocos/editor-support/cocostudio/ObjectFactory.cpp
@@ -143,7 +143,7 @@ Component* ObjectFactory::createComponent(const std::string &name)
     
 ui::Widget* ObjectFactory::createGUI(std::string name)
 {
-    Object* object = NULL;
+    Ref* object = nullptr;
     
     if (name == "Panel")
     {
@@ -182,7 +182,7 @@ ui::Widget* ObjectFactory::createGUI(std::string name)
 
 WidgetReaderProtocol* ObjectFactory::createWidgetReaderProtocol(std::string name)
 {
-    Object* object = NULL;
+    Ref* object = NULL;
     
     do
     {
diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj
index 64c6b685f2..63eca00029 100644
--- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj
+++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj
@@ -932,7 +932,12 @@
 				);
 				HEADER_SEARCH_PATHS = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 5.1;
-				LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios";
+				LIBRARY_SEARCH_PATHS = (
+					"$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios",
+					"$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios",
+				);
+				"OTHER_LDFLAGS[arch=arm64]" = "-llua";
+				"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
 				SDKROOT = iphoneos;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../2d/platform/ios";
@@ -952,7 +957,12 @@
 				);
 				HEADER_SEARCH_PATHS = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 5.1;
-				LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios";
+				LIBRARY_SEARCH_PATHS = (
+					"$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios",
+					"$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios",
+				);
+				"OTHER_LDFLAGS[arch=arm64]" = "-llua";
+				"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
 				SDKROOT = iphoneos;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../2d/platform/ios";
diff --git a/cocos/ui/GUIDefine.h b/cocos/ui/GUIDefine.h
index 8cd44b664a..788439e7aa 100644
--- a/cocos/ui/GUIDefine.h
+++ b/cocos/ui/GUIDefine.h
@@ -30,9 +30,9 @@
 #include <string>
 #include "cocostudio/ObjectFactory.h"
 
-#pragma mark -
-#pragma mark Widget macro
-#pragma mark -
+//#pragma mark -
+//#pragma mark Widget macro
+//#pragma mark -
 
 #define DECLARE_CLASS_GUI_INFO \
     public: \
@@ -50,9 +50,9 @@
     cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \
 
 
-#pragma mark -
-#pragma mark Reader macro
-#pragma mark -
+//#pragma mark -
+//#pragma mark Reader macro
+//#pragma mark -
 
 #define DECLARE_CLASS_WIDGET_READER_INFO \
     public: \
diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp
index 941bdf0b46..63c21a2fc1 100644
--- a/cocos/ui/UIButton.cpp
+++ b/cocos/ui/UIButton.cpp
@@ -436,7 +436,7 @@ void Button::updateFlippedX()
     _titleRenderer->setFlippedX(_flippedX);
     if (_scale9Enabled)
     {
-        int flip = _flippedX ? -1 : 1;
+        float flip = _flippedX ? -1.0f : 1.0f;
         _buttonNormalRenderer->setScaleX(flip);
         _buttonClickedRenderer->setScaleX(flip);
         _buttonDisableRenderer->setScaleX(flip);
@@ -454,7 +454,7 @@ void Button::updateFlippedY()
     _titleRenderer->setFlippedY(_flippedY);
     if (_scale9Enabled)
     {
-        int flip = _flippedY ? -1 : 1;
+        float flip = _flippedY ? -1.0f : 1.0f;
         _buttonNormalRenderer->setScaleY(flip);
         _buttonClickedRenderer->setScaleY(flip);
         _buttonDisableRenderer->setScaleY(flip);
diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h
index f525ab870a..bf82af234a 100644
--- a/cocos/ui/UILayout.h
+++ b/cocos/ui/UILayout.h
@@ -154,11 +154,11 @@ public:
     
     const Point& getBackGroundColorVector();
     
-    void setBackGroundImageColor(const ccColor3B& color);
+    void setBackGroundImageColor(const Color3B& color);
     
     void setBackGroundImageOpacity(GLubyte opacity);
     
-    const ccColor3B& getBackGroundImageColor();
+    const Color3B& getBackGroundImageColor();
     
     GLubyte getBackGroundImageOpacity();
     
diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp
index 8e153ec123..a9099ad291 100644
--- a/cocos/ui/UIRichText.cpp
+++ b/cocos/ui/UIRichText.cpp
@@ -340,7 +340,7 @@ void RichText::formarRenderers()
         float newContentSizeHeight = 0.0f;
         float *maxHeights = new float[_elementRenders.size()];
         
-        for (int i=0; i<_elementRenders.size(); i++)
+        for (size_t i=0; i<_elementRenders.size(); i++)
         {
             Vector<Node*>* row = (_elementRenders[i]);
             float maxHeight = 0.0f;
@@ -355,7 +355,7 @@ void RichText::formarRenderers()
         
         
         float nextPosY = _customSize.height;
-        for (int i=0; i<_elementRenders.size(); i++)
+        for (size_t i=0; i<_elementRenders.size(); i++)
         {
             Vector<Node*>* row = (_elementRenders[i]);
             float nextPosX = 0.0f;
@@ -374,7 +374,7 @@ void RichText::formarRenderers()
         delete [] maxHeights;
     }
     
-    int length = _elementRenders.size();
+    size_t length = _elementRenders.size();
     for (size_t i = 0; i<length; i++)
 	{
         Vector<Node*>* l = _elementRenders[i];
diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp
index 3459f9e2ec..9b0068f26f 100644
--- a/cocos/ui/UIWidget.cpp
+++ b/cocos/ui/UIWidget.cpp
@@ -1020,8 +1020,8 @@ void Widget::copyProperties(Widget *widget)
     setScaleX(widget->getScaleX());
     setScaleY(widget->getScaleY());
     setRotation(widget->getRotation());
-    setRotationX(widget->getRotationX());
-    setRotationY(widget->getRotationY());
+    setRotationSkewX(widget->getRotationSkewX());
+    setRotationSkewY(widget->getRotationSkewY());
     setFlippedX(widget->isFlippedX());
     setFlippedY(widget->isFlippedY());
     setColor(widget->getColor());
diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md
index d693a3809e..b354e0b892 100644
--- a/docs/RELEASE_NOTES.md
+++ b/docs/RELEASE_NOTES.md
@@ -91,8 +91,8 @@ You can run the samples...
     $ cd cocos2d-x
     $ ./setup.py
     $ cd build
-    $ ./android-build.py -p 10
-    $ adb install cocos2d-x/tests/proj.android/bin/TestDemo-debug.apk
+    $ ./android-build.py cpp-empty-test -p 10
+    $ adb install cocos2d-x/tests/cpp-empty-test/proj.android/bin/CppEmptyTest-debug.apk
     
 Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10.
 
@@ -101,18 +101,18 @@ Then click item on Android device to run tests. Available value of `-p` is the A
     $ cd cocos2d-x
     $ ./setup.py
     $ cd build
-    $ ./android-build.py
+    $ ./android-build.py cpp-empty-test -p 10
     
 Then
 
 * Import cocos2d-x Android project into Eclipse, the path used to import is `cocos/2d/platform/android`
-* Import `tests` Android project into Eclipse, the path used to import is `tests/proj.android`
-* Build `tests` Android project and run
+* Import `cpp-empty-test` Android project into Eclipse, the path used to import is `tests/cpp-empty-test/proj.android`
+* Build `cpp-empty-test` Android project and run
 
 ### Windows
 
 * Enter `cocos2d-x/build`, and open `cocos2d-win32.vs2012.sln`
-* Select `TestCpp` as running target
+* Select `cpp-empty-test` as running target
 * Click run button
 
 
@@ -126,23 +126,17 @@ Then
 
     $ mkdir build
     $ cd build
-    $ cmake ..
+    $ cmake ../cocos2d-x
     $ make -j4
     
 Run
 
-    $ cd bin/testcpp
-    $ ./testcpp
+    $ cd bin/cpp-empty-test
+    $ ./cpp-empty-test
     
 ## How to start a new game
 
-    $ cd cocos2d-x
-    $ ./setup.py
-    $ source FILE_TO_RECORD_SYSTEM_VARIABLE
-`FILE_TO_RECORD_SYSTEM_VARIABLE` may be `~/.bash_profile`, `~/.bash_login` or `~./.profile`
-
-    $ cocos new MyGame -p com.MyCompany.MyGame -l cpp -d directory_to_save
-Because `cocos run` command is not ready, so you should do it manually as running `TestCpp`. After `cocos run` command is finished, can just run `cocos run` to run the new game on demand target.
+Please refer to [ReadMe](../README.md)
     
 
 # Highlights of v3.0
diff --git a/external/curl/include/ios/curl/curlbuild.h b/external/curl/include/ios/curl/curlbuild.h
index c24099a90a..3397c39b61 100644
--- a/external/curl/include/ios/curl/curlbuild.h
+++ b/external/curl/include/ios/curl/curlbuild.h
@@ -171,13 +171,13 @@ typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
 typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
 
 /* curl_off_t formatting string directive without "%" conversion specifier. */
-#define CURL_FORMAT_CURL_OFF_T "lld"
+#define CURL_FORMAT_CURL_OFF_T PRId64
 
 /* unsigned curl_off_t formatting string without "%" conversion specifier. */
-#define CURL_FORMAT_CURL_OFF_TU "llu"
+#define CURL_FORMAT_CURL_OFF_TU PRIu64
 
 /* curl_off_t formatting string directive with "%" conversion specifier. */
-#define CURL_FORMAT_OFF_T "%lld"
+#define CURL_FORMAT_OFF_T "%" PRId64
 
 /* The size of `curl_off_t', as computed by sizeof. */
 #define CURL_SIZEOF_CURL_OFF_T 8
diff --git a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id
index a3971cdd23..b832ed4fb2 100644
--- a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id
+++ b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id
@@ -1 +1 @@
-c135286e812602cc184684b59b4d074f723ef4a5
\ No newline at end of file
+dc1d98e73cda98024add3420a06fa29651c863d0
\ No newline at end of file
diff --git a/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..709ec42a2a
--- /dev/null
+++ b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+9b09288998b6198388456c41ccbdd5596622abe5
\ No newline at end of file
diff --git a/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id b/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id
index f7532b4633..6f0e868417 100644
--- a/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id
+++ b/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id
@@ -1 +1 @@
-3303f759eb8c682843322ffa9f8c69563d241ca5
\ No newline at end of file
+81b071fde15c160fb96e2b28a22142e903fdf5a4
\ No newline at end of file
diff --git a/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id b/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..5bae8cd871
--- /dev/null
+++ b/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+690402fd689da9d29621e7665db2f40ac4e947eb
\ No newline at end of file
diff --git a/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id b/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id
index 5434a2f27c..a366f9fbac 100644
--- a/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id
+++ b/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id
@@ -1 +1 @@
-39c4d5970691b3a3ca47be0f7d2a0b5c72e9e2ee
\ No newline at end of file
+e8281e5ccfc438a1d097b9704010312801ea192e
\ No newline at end of file
diff --git a/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id b/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..11f4aa8c76
--- /dev/null
+++ b/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+dd93f7d77c23392642750b58fb0f41eda9218b69
\ No newline at end of file
diff --git a/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id b/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id
index 78b5e3634d..fdea42a702 100644
--- a/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id
+++ b/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id
@@ -1 +1 @@
-fc2d13f253f62b28ad1d37a4a24da1e977acba20
\ No newline at end of file
+d8eeb3fe1c71ca56139f7e31f0b502da876c692b
\ No newline at end of file
diff --git a/external/lua/lua/lbaselib.c b/external/lua/lua/lbaselib.c
index 2ab550bd48..2a4c079d3b 100644
--- a/external/lua/lua/lbaselib.c
+++ b/external/lua/lua/lbaselib.c
@@ -631,7 +631,7 @@ static void base_open (lua_State *L) {
   luaL_register(L, "_G", base_funcs);
   lua_pushliteral(L, LUA_VERSION);
   lua_setglobal(L, "_VERSION");  /* set global _VERSION */
-  /* `ipairs' and `pairs' need auxiliary functions as upvalues */
+  /* `ipairs' and `pairs' need auxliliary functions as upvalues */
   auxopen(L, "ipairs", luaB_ipairs, ipairsaux);
   auxopen(L, "pairs", luaB_pairs, luaB_next);
   /* `newproxy' needs a weaktable as upvalue */
diff --git a/external/lua/lua/lcode.c b/external/lua/lua/lcode.c
index 679cb9cfd9..cff626b7fa 100644
--- a/external/lua/lua/lcode.c
+++ b/external/lua/lua/lcode.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -544,6 +544,10 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) {
       pc = NO_JUMP;  /* always true; do nothing */
       break;
     }
+    case VFALSE: {
+      pc = luaK_jump(fs);  /* always jump */
+      break;
+    }
     case VJMP: {
       invertjump(fs, e);
       pc = e->u.s.info;
@@ -568,6 +572,10 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) {
       pc = NO_JUMP;  /* always false; do nothing */
       break;
     }
+    case VTRUE: {
+      pc = luaK_jump(fs);  /* always jump */
+      break;
+    }
     case VJMP: {
       pc = e->u.s.info;
       break;
diff --git a/external/lua/lua/ldblib.c b/external/lua/lua/ldblib.c
index 2027eda598..67de1222a9 100644
--- a/external/lua/lua/ldblib.c
+++ b/external/lua/lua/ldblib.c
@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -45,7 +45,6 @@ static int db_setmetatable (lua_State *L) {
 
 
 static int db_getfenv (lua_State *L) {
-  luaL_checkany(L, 1);
   lua_getfenv(L, 1);
   return 1;
 }
diff --git a/external/lua/lua/ldo.c b/external/lua/lua/ldo.c
index d1bf786cb7..8de05f728e 100644
--- a/external/lua/lua/ldo.c
+++ b/external/lua/lua/ldo.c
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -217,7 +217,6 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
     int nvar = actual - nfixargs;  /* number of extra arguments */
     lua_assert(p->is_vararg & VARARG_HASARG);
     luaC_checkGC(L);
-    luaD_checkstack(L, p->maxstacksize);
     htab = luaH_new(L, nvar, 1);  /* create `arg' table */
     for (i=0; i<nvar; i++)  /* put extra arguments into `arg' table */
       setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
diff --git a/external/lua/lua/lgc.c b/external/lua/lua/lgc.c
index e909c79a96..d9e0b78294 100644
--- a/external/lua/lua/lgc.c
+++ b/external/lua/lua/lgc.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -627,6 +627,7 @@ void luaC_step (lua_State *L) {
     }
   }
   else {
+    lua_assert(g->totalbytes >= g->estimate);
     setthreshold(g);
   }
 }
diff --git a/external/lua/lua/liolib.c b/external/lua/lua/liolib.c
index e072056ca1..e79ed1cb2e 100644
--- a/external/lua/lua/liolib.c
+++ b/external/lua/lua/liolib.c
@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -180,13 +180,11 @@ static int io_popen (lua_State *L) {
 }
 
 
-#ifndef __native_client__
 static int io_tmpfile (lua_State *L) {
   FILE **pf = newfile(L);
   *pf = tmpfile();
   return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
 }
-#endif
 
 
 static FILE *getiofile (lua_State *L, int findex) {
@@ -278,10 +276,7 @@ static int read_number (lua_State *L, FILE *f) {
     lua_pushnumber(L, d);
     return 1;
   }
-  else {
-    lua_pushnil(L);  /* "result" to be removed */
-    return 0;  /* read fails */
-  }
+  else return 0;  /* read fails */
 }
 
 
@@ -488,9 +483,7 @@ static const luaL_Reg iolib[] = {
   {"output", io_output},
   {"popen", io_popen},
   {"read", io_read},
-#ifndef __native_client__
   {"tmpfile", io_tmpfile},
-#endif
   {"type", io_type},
   {"write", io_write},
   {NULL, NULL}
diff --git a/external/lua/lua/llex.c b/external/lua/lua/llex.c
index 77afcdedc7..6dc319358c 100644
--- a/external/lua/lua/llex.c
+++ b/external/lua/lua/llex.c
@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -118,10 +118,8 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
   lua_State *L = ls->L;
   TString *ts = luaS_newlstr(L, str, l);
   TValue *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
-  if (ttisnil(o)) {
+  if (ttisnil(o))
     setbvalue(o, 1);  /* make sure `str' will not be collected */
-    luaC_checkGC(L);
-  }
   return ts;
 }
 
@@ -178,9 +176,9 @@ static void buffreplace (LexState *ls, char from, char to) {
 
 static void trydecpoint (LexState *ls, SemInfo *seminfo) {
   /* format error: try to update decimal point separator */
-  /* struct lconv *cv = localeconv(); removed for android ndk */
+  struct lconv *cv = localeconv();
   char old = ls->decpoint;
-  ls->decpoint = '.'; /* (cv ? cv->decimal_point[0] : '.'); removed for android ndk */
+  ls->decpoint = (cv ? cv->decimal_point[0] : '.');
   buffreplace(ls, old, ls->decpoint);  /* try updated decimal separator */
   if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
     /* format error with correct decimal point: no more options */
diff --git a/external/lua/lua/loadlib.c b/external/lua/lua/loadlib.c
index 6158c5353d..0d401eba1c 100644
--- a/external/lua/lua/loadlib.c
+++ b/external/lua/lua/loadlib.c
@@ -1,5 +1,5 @@
 /*
-** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
 ** Dynamic library loader for Lua
 ** See Copyright Notice in lua.h
 **
@@ -639,7 +639,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
   lua_pushvalue(L, -1);
   lua_replace(L, LUA_ENVIRONINDEX);
   /* create `loaders' table */
-  lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
+  lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
   /* fill it with pre-defined loaders */
   for (i=0; loaders[i] != NULL; i++) {
     lua_pushcfunction(L, loaders[i]);
diff --git a/external/lua/lua/loslib.c b/external/lua/lua/loslib.c
index 3443907973..da06a572ac 100644
--- a/external/lua/lua/loslib.c
+++ b/external/lua/lua/loslib.c
@@ -35,12 +35,10 @@ static int os_pushresult (lua_State *L, int i, const char *filename) {
 }
 
 
-#ifndef __native_client__
 static int os_execute (lua_State *L) {
   lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
   return 1;
 }
-#endif
 
 
 static int os_remove (lua_State *L) {
@@ -223,9 +221,7 @@ static const luaL_Reg syslib[] = {
   {"clock",     os_clock},
   {"date",      os_date},
   {"difftime",  os_difftime},
-#ifndef __native_client__
   {"execute",   os_execute},
-#endif
   {"exit",      os_exit},
   {"getenv",    os_getenv},
   {"remove",    os_remove},
diff --git a/external/lua/lua/lparser.c b/external/lua/lua/lparser.c
index dda7488dca..1e2a9a88b7 100644
--- a/external/lua/lua/lparser.c
+++ b/external/lua/lua/lparser.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $
+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -374,9 +374,9 @@ static void close_func (LexState *ls) {
   lua_assert(luaG_checkcode(f));
   lua_assert(fs->bl == NULL);
   ls->fs = fs->prev;
+  L->top -= 2;  /* remove table and prototype from the stack */
   /* last token read was anchored in defunct function; must reanchor it */
   if (fs) anchor_token(ls);
-  L->top -= 2;  /* remove table and prototype from the stack */
 }
 
 
diff --git a/external/lua/lua/lstrlib.c b/external/lua/lua/lstrlib.c
index 7a03489beb..1b4763d4ee 100644
--- a/external/lua/lua/lstrlib.c
+++ b/external/lua/lua/lstrlib.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -754,7 +754,6 @@ static void addintlen (char *form) {
 
 
 static int str_format (lua_State *L) {
-  int top = lua_gettop(L);
   int arg = 1;
   size_t sfl;
   const char *strfrmt = luaL_checklstring(L, arg, &sfl);
@@ -769,8 +768,7 @@ static int str_format (lua_State *L) {
     else { /* format item */
       char form[MAX_FORMAT];  /* to store the format (`%...') */
       char buff[MAX_ITEM];  /* to store the formatted item */
-      if (++arg > top)
-        luaL_argerror(L, arg, "no value");
+      arg++;
       strfrmt = scanformat(L, strfrmt, form);
       switch (*strfrmt++) {
         case 'c': {
diff --git a/external/lua/lua/lua.c b/external/lua/lua/lua.c
index 3add3ee1c5..3a46609328 100644
--- a/external/lua/lua/lua.c
+++ b/external/lua/lua/lua.c
@@ -336,3 +336,57 @@ struct Smain {
   int status;
 };
 
+
+static int pmain (lua_State *L) {
+  struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
+  char **argv = s->argv;
+  int script;
+  int has_i = 0, has_v = 0, has_e = 0;
+  globalL = L;
+  if (argv[0] && argv[0][0]) progname = argv[0];
+  lua_gc(L, LUA_GCSTOP, 0);  /* stop collector during initialization */
+  luaL_openlibs(L);  /* open libraries */
+  lua_gc(L, LUA_GCRESTART, 0);
+  s->status = handle_luainit(L);
+  if (s->status != 0) return 0;
+  script = collectargs(argv, &has_i, &has_v, &has_e);
+  if (script < 0) {  /* invalid args? */
+    print_usage();
+    s->status = 1;
+    return 0;
+  }
+  if (has_v) print_version();
+  s->status = runargs(L, argv, (script > 0) ? script : s->argc);
+  if (s->status != 0) return 0;
+  if (script)
+    s->status = handle_script(L, argv, script);
+  if (s->status != 0) return 0;
+  if (has_i)
+    dotty(L);
+  else if (script == 0 && !has_e && !has_v) {
+    if (lua_stdin_is_tty()) {
+      print_version();
+      dotty(L);
+    }
+    else dofile(L, NULL);  /* executes stdin as a file */
+  }
+  return 0;
+}
+
+
+int main (int argc, char **argv) {
+  int status;
+  struct Smain s;
+  lua_State *L = lua_open();  /* create state */
+  if (L == NULL) {
+    l_message(argv[0], "cannot create state: not enough memory");
+    return EXIT_FAILURE;
+  }
+  s.argc = argc;
+  s.argv = argv;
+  status = lua_cpcall(L, &pmain, &s);
+  report(L, status);
+  lua_close(L);
+  return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
diff --git a/external/lua/lua/lua.h b/external/lua/lua/lua.h
index a4b73e743e..e4bdfd3b94 100644
--- a/external/lua/lua/lua.h
+++ b/external/lua/lua/lua.h
@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
+** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
 ** Lua - An Extensible Extension Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
 
 
 #define LUA_VERSION	"Lua 5.1"
-#define LUA_RELEASE	"Lua 5.1.5"
+#define LUA_RELEASE	"Lua 5.1.4"
 #define LUA_VERSION_NUM	501
-#define LUA_COPYRIGHT	"Copyright (C) 1994-2012 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT	"Copyright (C) 1994-2008 Lua.org, PUC-Rio"
 #define LUA_AUTHORS 	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
 
 
@@ -362,7 +362,7 @@ struct lua_Debug {
 
 
 /******************************************************************************
-* Copyright (C) 1994-2012 Lua.org, PUC-Rio.  All rights reserved.
+* Copyright (C) 1994-2008 Lua.org, PUC-Rio.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
diff --git a/external/lua/lua/lvm.c b/external/lua/lua/lvm.c
index e0a0cd8521..ee3256ab94 100644
--- a/external/lua/lua/lvm.c
+++ b/external/lua/lua/lvm.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -133,7 +133,6 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
 
 void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
   int loop;
-  TValue temp;
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
     const TValue *tm;
     if (ttistable(t)) {  /* `t' is a table? */
@@ -142,7 +141,6 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
       if (!ttisnil(oldval) ||  /* result is no nil? */
           (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
         setobj2t(L, oldval, val);
-        h->flags = 0;
         luaC_barriert(L, h, val);
         return;
       }
@@ -154,9 +152,7 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
       callTM(L, tm, t, key, val);
       return;
     }
-    /* else repeat with `tm' */
-    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */
-    t = &temp;
+    t = tm;  /* else repeat with `tm' */ 
   }
   luaG_runerror(L, "loop in settable");
 }
diff --git a/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id b/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id
new file mode 100644
index 0000000000..1133a98d05
--- /dev/null
+++ b/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id
@@ -0,0 +1 @@
+a064ce4dee79c042cebd3ab706673cd2a7bc4a4e
\ No newline at end of file
diff --git a/external/png/prebuilt/ios/libpng.a.REMOVED.git-id b/external/png/prebuilt/ios/libpng.a.REMOVED.git-id
index adbc13a75d..2d0321bd96 100644
--- a/external/png/prebuilt/ios/libpng.a.REMOVED.git-id
+++ b/external/png/prebuilt/ios/libpng.a.REMOVED.git-id
@@ -1 +1 @@
-2a8128e7d552dc8b2d79c1cbd8c84c21ad578672
\ No newline at end of file
+c4decf3cb39b46189df24c54868f46e985b15de2
\ No newline at end of file
diff --git a/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id b/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..9907c43b6c
--- /dev/null
+++ b/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+13d38a8f7cf04ee464b3eaf5fd7464853499390e
\ No newline at end of file
diff --git a/external/png/prebuilt/mac/libpng.a.REMOVED.git-id b/external/png/prebuilt/mac/libpng.a.REMOVED.git-id
index 9d858ddb88..a3f9f5fe04 100644
--- a/external/png/prebuilt/mac/libpng.a.REMOVED.git-id
+++ b/external/png/prebuilt/mac/libpng.a.REMOVED.git-id
@@ -1 +1 @@
-fb78024e2f81c33d196af83e7740de7c7f4ea021
\ No newline at end of file
+373f86ef034bf18f5d52588747c02d7896884730
\ No newline at end of file
diff --git a/external/tiff/include/ios/tiffconf.h b/external/tiff/include/ios/tiffconf.h
index 4322c323af..9a53f1497b 100644
--- a/external/tiff/include/ios/tiffconf.h
+++ b/external/tiff/include/ios/tiffconf.h
@@ -15,7 +15,7 @@
 #define TIFF_INT32_T signed int
 
 /* Signed 64-bit type */
-#define TIFF_INT64_T signed long long
+#define TIFF_INT64_T int64_t
 
 /* Signed 8-bit type */
 #define TIFF_INT8_T signed char
@@ -27,7 +27,7 @@
 #define TIFF_UINT32_T unsigned int
 
 /* Unsigned 64-bit type */
-#define TIFF_UINT64_T unsigned long long
+#define TIFF_UINT64_T uint64_t
 
 /* Unsigned 8-bit type */
 #define TIFF_UINT8_T unsigned char
diff --git a/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id b/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id
index 1305bb3f84..75a747bf14 100644
--- a/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id
+++ b/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id
@@ -1 +1 @@
-60433133a48054eb884d9e6a0cee95fe4ba22b1c
\ No newline at end of file
+286c39ddabb05b91c81ee5d7ec0a1301d0be3108
\ No newline at end of file
diff --git a/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id b/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..2a9acad1ea
--- /dev/null
+++ b/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+39aa0b352df6cb1adf2390cf199910b21a3b3c12
\ No newline at end of file
diff --git a/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id b/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id
index 4cc30a45bb..89f7a5119a 100644
--- a/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id
+++ b/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id
@@ -1 +1 @@
-5fe8aca7e0bfa91c79b4b6b0a562f88a6653c452
\ No newline at end of file
+e5cd88ead5723950d6f69e8bd72b4b18b2f9d893
\ No newline at end of file
diff --git a/external/version.txt b/external/version.txt
new file mode 100644
index 0000000000..bdd7244465
--- /dev/null
+++ b/external/version.txt
@@ -0,0 +1,9 @@
+libs          version
+———————————————————
+freetype      2.5.0
+curl          7.26.0
+jpeg          9.0
+png           1.6.2
+tiff          4.0.3
+webp          0.2.1
+websockets    v1.23-chrome32-firefox24
\ No newline at end of file
diff --git a/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id b/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id
index f782a7af53..46ccff2586 100644
--- a/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id
+++ b/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id
@@ -1 +1 @@
-c26c3c22887023d322926dcbbd0f69377deedaf8
\ No newline at end of file
+7f9f32e81cbd068ab7a9c408a26eedfdcc8d6e30
\ No newline at end of file
diff --git a/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id b/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id
new file mode 100644
index 0000000000..c5dff9b151
--- /dev/null
+++ b/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id
@@ -0,0 +1 @@
+904e2e16f2f4846b4550b9ba25e8b709f6c4337e
\ No newline at end of file
diff --git a/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id b/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id
index 7a441fa135..fb37e15f1a 100644
--- a/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id
+++ b/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id
@@ -1 +1 @@
-4c5c7d34a90f5fcac954f6d44803173224d8ead2
\ No newline at end of file
+6b5decfe3f5b19bacfbd9778cb58843a7161a6a9
\ No newline at end of file
diff --git a/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id b/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id
index 08dc34e960..51c418cdb9 100644
--- a/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id
+++ b/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id
@@ -1 +1 @@
-ee4ee6cc26274f6d3138d08d429d6ba49b629f53
\ No newline at end of file
+5c60f0b27edd2650caee8a96948272604a8098d5
\ No newline at end of file
diff --git a/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id b/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id
index bdf504bf24..0badadb7b2 100644
--- a/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id
+++ b/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id
@@ -1 +1 @@
-5d0743ce07a9c865d4367d8e3db161148676f2c8
\ No newline at end of file
+36c2d4cb652d9a93fa2a285cb8c73f237612bb46
\ No newline at end of file
diff --git a/setup.py b/setup.py
index b39c0d5d88..da1948c713 100755
--- a/setup.py
+++ b/setup.py
@@ -351,7 +351,7 @@ class SetEnvVar(object):
             ndk_root = self._get_input_value()
 
         if ndk_root and not self._is_ndk_root_valid(ndk_root) and not ndk_root_found:
-            print 'Error: %s is not a valid path of NDK_ROOT. Ignoring it.' % ndk_root
+            print 'Error: "%s" is not a valid path of NDK_ROOT. Ignoring it.' % ndk_root
 
         if ndk_root_found:
             print 'FOUND'
@@ -377,7 +377,7 @@ class SetEnvVar(object):
             android_sdk_root = self._get_input_value()
         
         if android_sdk_root and not self._is_android_sdk_root_valid(android_sdk_root) and not android_sdk_root_found:
-            print 'Error: %s is not a valid path of ANDROID_SDK_ROOT. Ignoring it.' % android_sdk_root
+            print 'Error: "%s" is not a valid path of ANDROID_SDK_ROOT. Ignoring it.' % android_sdk_root
 
         if android_sdk_root_found:
             print 'FOUND'
@@ -401,7 +401,7 @@ class SetEnvVar(object):
             ant_root = self._get_input_value()
 
         if ant_root and not self._is_ant_root_valid(ant_root) and not ant_found:
-            print 'Error: %s is not a valid path of ANT_ROOT. Ignoring it.' % ant_root
+            print 'Error: "%s" is not a valid path of ANT_ROOT. Ignoring it.' % ant_root
 
 
         if ant_found:
@@ -433,7 +433,7 @@ class SetEnvVar(object):
             print '\nCOCOS_CONSOLE_ROOT was already added. Edit "%s" for manual changes' % target   
 
         if self._isWindows():
-            print '\nPlease restart the terminal to make added system variables take effect'
+            print '\nPlease restart the terminal or restart computer to make added system variables take effect'
         else:
             print '\nPlease execute command: "source %s" to make added system variables take effect' % target
 
@@ -441,7 +441,7 @@ if __name__ == '__main__':
     parser = OptionParser()
     parser.add_option('-n', '--ndkroot', dest='ndk_root', help='directory of ndk root')
     parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root')
-    parser.add_option('-t', '--antroot', dest='ant_root', help='directory of ant root')
+    parser.add_option('-t', '--antroot', dest='ant_root', help='directory that contains ant/ant.bat')
     opts, args = parser.parse_args()
 
     # set environment variables
diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id
index d92bc84e3a..5bd936f744 100644
--- a/templates/cocos2dx_files.json.REMOVED.git-id
+++ b/templates/cocos2dx_files.json.REMOVED.git-id
@@ -1 +1 @@
-725d085b1800d788b0a8cf1ec615d750573dce15
\ No newline at end of file
+4dfa7f46c2e06a4b3b95120bea3b8689f31ddad0
\ No newline at end of file
diff --git a/templates/lua-template-default/frameworks/CMakeLists.txt b/templates/lua-template-default/frameworks/CMakeLists.txt
new file mode 100644
index 0000000000..33c9f28fc9
--- /dev/null
+++ b/templates/lua-template-default/frameworks/CMakeLists.txt
@@ -0,0 +1,182 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(APP_NAME HelloLua)
+project (${APP_NAME})
+
+include(cocos2d-x/build/BuildHelpers.CMakeLists.txt)
+
+option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
+option(USE_BOX2D "Use box2d for physics library" OFF)
+option(DEBUG_MODE "Debug or release?" ON)
+
+if(DEBUG_MODE)
+  set(CMAKE_BUILD_TYPE DEBUG)
+else(DEBUG_MODE)
+  set(CMAKE_BUILD_TYPE RELEASE)
+endif(DEBUG_MODE)
+
+set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
+set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99")
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
+
+if(USE_CHIPMUNK)
+  message("Using chipmunk ...")
+  add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
+elseif(USE_BOX2D)
+  message("Using box2d ...")
+  add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
+else(USE_CHIPMUNK)
+  message(FATAL_ERROR "Must choose a physics library.")
+endif(USE_CHIPMUNK)
+
+# architecture
+if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+set(ARCH_DIR "64-bit")
+else()
+set(ARCH_DIR "32-bit")
+endif()
+
+
+set(GAME_SRC
+  runtime-src/proj.linux/main.cpp
+  runtime-src/Classes/AppDelegate.cpp
+)
+
+set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d-x)
+
+include_directories(
+  /usr/include
+  /usr/include/GLFW
+  /usr/local/include/GLFW
+  runtime-src/Classes
+  ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/manual
+  ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/auto
+  ${COCOS2D_ROOT}/external/lua/lua
+  ${COCOS2D_ROOT}/external/lua/tolua
+  ${COCOS2D_ROOT}
+  ${COCOS2D_ROOT}/cocos
+  ${COCOS2D_ROOT}/cocos/audio/include
+  ${COCOS2D_ROOT}/cocos/2d
+  ${COCOS2D_ROOT}/cocos/2d/renderer
+  ${COCOS2D_ROOT}/cocos/2d/platform
+  ${COCOS2D_ROOT}/cocos/2d/platform/desktop
+  ${COCOS2D_ROOT}/cocos/2d/platform/linux
+  ${COCOS2D_ROOT}/cocos/base
+  ${COCOS2D_ROOT}/cocos/physics
+  ${COCOS2D_ROOT}/cocos/editor-support
+  ${COCOS2D_ROOT}/cocos/math/kazmath
+  ${COCOS2D_ROOT}/extensions
+  ${COCOS2D_ROOT}/external
+  ${COCOS2D_ROOT}/external/edtaa3func
+  ${COCOS2D_ROOT}/external/jpeg/include/linux
+  ${COCOS2D_ROOT}/external/tiff/include/linux
+  ${COCOS2D_ROOT}/external/webp/include/linux
+  ${COCOS2D_ROOT}/external/websockets/include/linux
+  ${COCOS2D_ROOT}/external/tinyxml2
+  ${COCOS2D_ROOT}/external/unzip
+  ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
+  ${COCOS2D_ROOT}/external/freetype2/include/linux
+  ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR}
+)
+
+link_directories(
+  /usr/local/lib
+  ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR}
+  ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR}
+  ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR}
+  ${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR}
+  ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR}
+  ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
+)
+
+# kazmath
+add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath)
+
+# chipmunk library
+add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src)
+
+# box2d library
+add_subdirectory(${COCOS2D_ROOT}/external/Box2D)
+
+# unzip library
+add_subdirectory(${COCOS2D_ROOT}/external/unzip)
+
+# tinyxml2 library
+add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)
+
+# audio
+add_subdirectory(${COCOS2D_ROOT}/cocos/audio)
+
+# cocos base library
+add_subdirectory(${COCOS2D_ROOT}/cocos/base)
+
+# cocos 2d library
+add_subdirectory(${COCOS2D_ROOT}/cocos/2d)
+
+# gui
+add_subdirectory(${COCOS2D_ROOT}/cocos/ui)
+
+# network
+add_subdirectory(${COCOS2D_ROOT}/cocos/network)
+
+# extensions
+add_subdirectory(${COCOS2D_ROOT}/extensions)
+
+## Editor Support
+
+# spine
+add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine)
+
+# cocosbuilder
+add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder)
+
+# cocostudio
+add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio)
+
+## Scripting
+# lua
+add_subdirectory(${COCOS2D_ROOT}/external/lua/lua)
+
+# tolua
+add_subdirectory(${COCOS2D_ROOT}/external/lua/tolua)
+
+# luabinding
+add_subdirectory(${COCOS2D_ROOT}/cocos/scripting/lua-bindings)
+
+# add the executable
+add_executable(${APP_NAME}
+  ${GAME_SRC}
+)
+
+if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+set(FMOD_LIB "fmodex64")
+else()
+set(FMOD_LIB "fmodex")
+endif()
+
+target_link_libraries(${APP_NAME}
+  luabinding
+  ui
+  network
+  spine
+  cocostudio
+  cocosbuilder
+  extensions
+  audio
+  cocos2d
+  )
+
+set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
+
+set_target_properties(${APP_NAME} PROPERTIES
+     RUNTIME_OUTPUT_DIRECTORY  "${APP_BIN_DIR}")
+
+pre_build(${APP_NAME}
+  COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
+  COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}/Resources/res
+  COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/Resources/src
+  COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script ${APP_BIN_DIR}/Resources
+  )
+  
diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp
new file mode 100644
index 0000000000..e420889600
--- /dev/null
+++ b/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp
@@ -0,0 +1,16 @@
+#include "../Classes/AppDelegate.h"
+#include "cocos2d.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string>
+
+USING_NS_CC;
+
+int main(int argc, char **argv)
+{
+    // create the application instance
+    AppDelegate app;
+    return Application::getInstance()->run();
+}
diff --git a/templates/lua-template-default/res/background.caf.REMOVED.git-id b/templates/lua-template-default/res/background.caf.REMOVED.git-id
new file mode 100644
index 0000000000..d8be9c833d
--- /dev/null
+++ b/templates/lua-template-default/res/background.caf.REMOVED.git-id
@@ -0,0 +1 @@
+5d7d0b8ce9780883a780ee5fd9e9317129b41643
\ No newline at end of file
diff --git a/templates/lua-template-default/src/main.lua b/templates/lua-template-default/src/main.lua
index 32bad3df7e..ec894a7787 100644
--- a/templates/lua-template-default/src/main.lua
+++ b/templates/lua-template-default/src/main.lua
@@ -204,8 +204,12 @@ local function main()
     -- play background music, preload effect
 
     -- uncomment below for the BlackBerry version
-    -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg")
-    local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3")
+    local bgMusicPath = nil 
+    if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
+        bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.caf")
+    else
+        bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3")
+    end
     cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true)
     local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav")
     cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath)
diff --git a/templates/lua-template-runtime/res/background.caf.REMOVED.git-id b/templates/lua-template-runtime/res/background.caf.REMOVED.git-id
new file mode 100644
index 0000000000..d8be9c833d
--- /dev/null
+++ b/templates/lua-template-runtime/res/background.caf.REMOVED.git-id
@@ -0,0 +1 @@
+5d7d0b8ce9780883a780ee5fd9e9317129b41643
\ No newline at end of file
diff --git a/templates/lua-template-runtime/src/main.lua b/templates/lua-template-runtime/src/main.lua
index 32bad3df7e..ec894a7787 100644
--- a/templates/lua-template-runtime/src/main.lua
+++ b/templates/lua-template-runtime/src/main.lua
@@ -204,8 +204,12 @@ local function main()
     -- play background music, preload effect
 
     -- uncomment below for the BlackBerry version
-    -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg")
-    local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3")
+    local bgMusicPath = nil 
+    if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
+        bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.caf")
+    else
+        bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3")
+    end
     cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true)
     local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav")
     cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath)
diff --git a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp
index 6ebcc144cc..d7115d58fb 100644
--- a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp
+++ b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp
@@ -16,6 +16,8 @@
     #define MUSIC_FILE        "music.mid"
 #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX )
     #define MUSIC_FILE        "background.ogg"
+#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
+    #define MUSIC_FILE        "background.caf"
 #else
     #define MUSIC_FILE        "background.mp3"
 #endif // CC_PLATFOR_WIN32
diff --git a/tests/cpp-tests/Resources/background.caf.REMOVED.git-id b/tests/cpp-tests/Resources/background.caf.REMOVED.git-id
new file mode 100644
index 0000000000..d8be9c833d
--- /dev/null
+++ b/tests/cpp-tests/Resources/background.caf.REMOVED.git-id
@@ -0,0 +1 @@
+5d7d0b8ce9780883a780ee5fd9e9317129b41643
\ No newline at end of file
diff --git a/tests/lua-empty-test/res/background.caf.REMOVED.git-id b/tests/lua-empty-test/res/background.caf.REMOVED.git-id
new file mode 100644
index 0000000000..d8be9c833d
--- /dev/null
+++ b/tests/lua-empty-test/res/background.caf.REMOVED.git-id
@@ -0,0 +1 @@
+5d7d0b8ce9780883a780ee5fd9e9317129b41643
\ No newline at end of file
diff --git a/tests/lua-empty-test/src/hello.lua b/tests/lua-empty-test/src/hello.lua
index 5bb47e5805..2916f16686 100644
--- a/tests/lua-empty-test/src/hello.lua
+++ b/tests/lua-empty-test/src/hello.lua
@@ -17,7 +17,7 @@ local function main()
     collectgarbage("setpause", 100)
     collectgarbage("setstepmul", 5000)
 
-    --support debug
+    --support debug,when used on ios7.1 64bit,these codes should be commented
     local targetPlatform = cc.Application:getInstance():getTargetPlatform()
     if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or 
        (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or
@@ -193,8 +193,13 @@ local function main()
     -- play background music, preload effect
 
     -- uncomment below for the BlackBerry version
-    -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.ogg")
-    local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3")
+    local bgMusicPath = nil 
+    if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
+        bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.caf")
+    else
+        bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3")
+    end
+
     cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true)
     local effectPath = cc.FileUtils:getInstance():fullPathForFilename("res/effect1.wav")
     cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath)
diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua
index 0fbe58efca..85d57230b9 100644
--- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua
+++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua
@@ -31,7 +31,7 @@ function AssetManagerModule.newScene(backfunc)
     helloLabel:setPosition(cc.p(winSize.width / 2, winSize.height - 40))
     layer:addChild(helloLabel, 5)
 
-    local sprite = cc.Sprite:create("background.png")
+    local sprite = cc.Sprite:create("Images/background.png")
     sprite:setAnchorPoint(cc.p(0.5, 0.5))
     sprite:setPosition(cc.p(winSize.width / 2, winSize.height / 2))
     layer:addChild(sprite, 0)
diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua
index eecbf1b83e..e0c1108ea7 100644
--- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua
+++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua
@@ -100,7 +100,8 @@ local function updateLayer()
     local function enter(sender)
 
         if not isUpdateItemClicked then
-            addSearchPath(pathToSave,true)
+            local realPath = pathToSave .. "/package"
+            addSearchPath(realPath,true)
         end
 
         assetsManagerModule = reloadModule("src/AssetsManagerTest/AssetsManagerModule")
diff --git a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua
index 89ec9223d8..36d054a636 100644
--- a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua
+++ b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua
@@ -1,6 +1,13 @@
 require "AudioEngine" 
 local EFFECT_FILE = "effect1.wav"
-local MUSIC_FILE  = "background.mp3"
+
+local MUSIC_FILE = nil 
+local targetPlatform = cc.Application:getInstance():getTargetPlatform()
+if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
+    MUSIC_FILE = "background.caf"
+else
+    MUSIC_FILE = "background.mp3"
+end
 
 local LINE_SPACE = 40
 
diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua
index 8afcc3bcda..77336f3475 100644
--- a/tests/lua-tests/src/mainMenu.lua
+++ b/tests/lua-tests/src/mainMenu.lua
@@ -149,6 +149,10 @@ function CreateTestMenu()
     CloseMenu:setPosition(0, 0)
     CloseMenu:addChild(CloseItem)
     menuLayer:addChild(CloseMenu)
+    local targetPlatform = cc.Application:getInstance():getTargetPlatform()       
+    if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
+        CloseMenu:setVisible(false)
+    end
 
     -- add menu items for tests
     local MainMenu = cc.Menu:create()
diff --git a/tools/bindings-generator b/tools/bindings-generator
index f2e408f1ce..34dfbf6497 160000
--- a/tools/bindings-generator
+++ b/tools/bindings-generator
@@ -1 +1 @@
-Subproject commit f2e408f1ce29df573b0ed6bbcc83cf9fd7a795d5
+Subproject commit 34dfbf64971a955995fe9762ab33ddbf907a1be3
diff --git a/tools/cocos2d-console b/tools/cocos2d-console
index 223a7cd9fd..67d0fd2ed7 160000
--- a/tools/cocos2d-console
+++ b/tools/cocos2d-console
@@ -1 +1 @@
-Subproject commit 223a7cd9fdf1d399ecb7b97346e2b5dea5f25331
+Subproject commit 67d0fd2ed79e5f7d52b797af897bf5cc23ef7994
diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini
index 57a9d5b369..9bdfe727ba 100644
--- a/tools/tolua/cocos2dx.ini
+++ b/tools/tolua/cocos2dx.ini
@@ -48,7 +48,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
         Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
         Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
         MenuItem.*::[create setCallback initWithCallback],
-        Label::[getLettersInfo createWithTTF setTTFConfig],
+        Label::[getLettersInfo createWithTTF setTTFConfig listenToBackground listenToFontAtlasPurge],
         Copying::[*],
         LabelProtocol::[*],
         LabelTextFormatProtocol::[*],