From 99c388ad8e45d2b9f9faced7c3a0827e5dddd6f9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Dec 2014 13:48:05 +0800 Subject: [PATCH 1/5] Fixed spine API usage in test case --- frameworks/cocos2d-html5 | 2 +- samples/js-tests/src/SpineTest/SpineTest.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index 213b869c19..2d17e00b23 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit 213b869c19daeb138b46944886514e2acea7b25c +Subproject commit 2d17e00b23a97f4d214a37ba0f54773d4c0eefc9 diff --git a/samples/js-tests/src/SpineTest/SpineTest.js b/samples/js-tests/src/SpineTest/SpineTest.js index dcbc236f79..c8e9db7b6d 100644 --- a/samples/js-tests/src/SpineTest/SpineTest.js +++ b/samples/js-tests/src/SpineTest/SpineTest.js @@ -82,7 +82,7 @@ var SpineTest = BaseTestLayer.extend({ // Make Spine's Animated skeleton Node // You need 'json + atlas + image' resource files to make it. // No JS binding for spine-c in this version. So, only file loading is supported. - var spineBoy = new sp.SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + var spineBoy = sp.SkeletonAnimation.create('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); spineBoy.setAnimation(0, 'walk', true); spineBoy.setMix('walk', 'jump', 0.2); From f1c11d6692ab921833fc30847bc1f3cba8c89654 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Dec 2014 16:11:43 +0800 Subject: [PATCH 2/5] 3.2 release docs --- AUTHORS | 2 + CHANGELOG | 36 +++++ ...e-note-v3.2rc0.md => release-note-v3.2.md} | 16 +-- docs/upgrade-guide-from-3.1-to-3.2.md | 127 ++++++++++++++++++ frameworks/cocos2d-html5 | 2 +- 5 files changed, 174 insertions(+), 9 deletions(-) rename docs/{release-note-v3.2rc0.md => release-note-v3.2.md} (87%) create mode 100644 docs/upgrade-guide-from-3.1-to-3.2.md diff --git a/AUTHORS b/AUTHORS index 62a4caf0cb..e4f2b9368f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -68,6 +68,8 @@ Igor Mats @IgorMats Added outline shader sample G17hao @G17hao Fixed an typo issue in jsb_boot.js +Simon de Lang @simondel Fixed use of deprecated cc, ccs and ccui create functions. + Cocos2d-JS can not grow so fast without the active community. Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups! Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions. diff --git a/CHANGELOG b/CHANGELOG index e255462f64..ccbc22db7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,41 @@ ChangeLog: +Cocos2d-JS v3.2 @ Dec.29, 2014 + +* Replaced `transform` function with `setTransform` function under canvas render mode for better performance. +* Added a timer in `cc.audioEngine` to check audio element loading event, prevent the loading process being stucked when load audio file failed. +* Added some new browser types to `cc.sys`. +* Added some audio resource loading codes to ensure compatibility with Wechat browser. +* Added check for WebAudio support to ensure compatibility. +* [JSB]Upgraded Cocos2d-x to v3.3 Final. +* [JSB]Added `getSearchPaths` API to `jsb.Manifest` to support better script hot update. +* [JSB]Polished restart game feature. +* [JSB]Added a sample usage case for `jsb.AssetsManager`'s script hot update ability. +* [JSB]Skipped FlatBuffer related bindings. +* [JSB]Canceled modifications in Spine due to License restriction and removed new constructor for `sp.SkeletonAnimation`. + +* Bug fixes: + 1. Fixed an issue that `cc.InputManager` doesn't trigger touch event on chrome mobile emulator. + 2. Fixed an issue that `cc.game.setFrameRate` doesn't work. + 3. Fixed an issue that `cc.view` can't remove resize event listener. + 4. Fixed an issue that `cc.EventManager` didn't set register flag to false when a listener is removed. + 5. Fixed an issue that `cc.audioEngine` doesn't play some audios on some iOS devices. + 6. Fixed an issue of ccui controls that their `setColor` doesn't work when cascade color is enabled. + 7. Fixed an issue that `ccs.Armature`'s `setColor` doesn't work in canvas render mode. + 8. Fixed an issue that `ccs.Armature` crashes when adding a child to it. + 9. Fixed an issue that `cc.SpriteBatchNode`'s status is incorrect in WebGL render mode. + 10. Fixed an issue of `cc.Layer` that its position is incorrect under bake mode. + 11. Fixed an issue of `ccui.RichText` that its `setContentSize` doesn't work. + 12. Fixed an issue of `cc.LabelTTF` that its `setColor` doesn't work when cascade color is enabled. + 13. Fixed an issue of spine that its skeletons position is incorrect when scaleX equals to -1 and scaleY equals to 1. + 14. Fixed `sp.Skeleton`'s API inconsistence by renaming `boundingBox` to `getBoundingBox`. + 15. Removed all usages of deprecated create functions in the test cases. + 16. [JSB]Fixed an issue of `ccui.ScrollView`'s `innerWidth` and `innerHeight` properties. + 17. [JSB]Fixed an issue that setting `cc.Node`'s userData property will crash. + 18. [JSB]Fixed API inconsistence by renaming `jsb.fileUtils`'s `getByteArrayFromFile` to `getDataFromFile`. + 19. [JSB]Fixed a script file cache check issue in ScriptingCore.cpp. + 20. [JSB]Fixed an issue of `ccs.Armature`'s constructore. + Cocos2d-JS v3.2 RC0 @ Dec.11, 2014 * Refactoration of web engine by separating the render logic, the arthictecture level refactoration is now completed and brounght great performance improvement. diff --git a/docs/release-note-v3.2rc0.md b/docs/release-note-v3.2.md similarity index 87% rename from docs/release-note-v3.2rc0.md rename to docs/release-note-v3.2.md index 4b91e0a709..f7347c28b8 100644 --- a/docs/release-note-v3.2rc0.md +++ b/docs/release-note-v3.2.md @@ -1,4 +1,4 @@ -# Cocos2d-JS v3.2 RC0 release note +# Cocos2d-JS v3.2 release note @@ -28,9 +28,9 @@ For JSB build, there are some restrictions : ## Download -- [Cocos2d-JS v3.2 RC0](http://www.cocos2d-x.org/filedown/cocos2d-js-v3.2-rc0.zip) +- [Cocos2d-JS v3.2](http://www.cocos2d-x.org/filedown/cocos2d-js-v3.2.zip) - [Online API reference](http://www.cocos2d-x.org/reference/html5-js/V3.0/index.html) -- [Downloadable API Reference](http://www.cocos2d-x.org/filedown/Cocos2d-JS-v3.2-RC0-API.zip) +- [Downloadable API Reference](http://www.cocos2d-x.org/filedown/Cocos2d-JS-v3.2-API.zip) - [Online test cases](http://cocos2d-x.org/js-tests/) ## Workflows @@ -45,14 +45,14 @@ For JSB build, there are some restrictions : Read more about all the features and bug fixes -- [Cocos2d-JS v3.2 RC0 changelog](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2rc0/changelog/en) -- [Cocos2d-JS v3.2 RC0 upgrade guide](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2rc0/upgrade-guide/en) +- [Cocos2d-JS v3.2 changelog](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2/changelog/en) +- [Cocos2d-JS v3.2 upgrade guide](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2rc0/upgrade-guide/en) ## Upgrade your project from previous versions -If you want to upgrade your game based on v3.0 previous version to the v3.2 RC0 version, you should follow these steps: +If you want to upgrade your game based on v3.x previous version to the v3.2 version, you should follow these steps: -1. Download the Cocos2d-JS v3.2 RC0 package. +1. Download the Cocos2d-JS v3.2 package. 2. Upgrade cocos command with `setup.py`. 3. Create a new project with `cocos new` command. 4. Replace the "src", "res", "index.html", "project.json", "main.js" etc with your old project. @@ -60,7 +60,7 @@ If you want to upgrade your game based on v3.0 previous version to the v3.2 RC0 ## About Cocos2d family -- Cocos2d-JS v3.2 RC0 uses Cocos2d-x v3.3rc1 as base of JSB solution +- Cocos2d-JS v3.2 uses Cocos2d-x v3.3 as base of JSB solution - Cocos2d-JS v3.2 is compatible with Cocos Code IDE v1.1.0 - Cocos2d-JS v3.2 is compatible with Cocos Studio v1.2 - v1.6, Cocos Studio 2 support have been removed because flat buffer binary file can't be parsed in JS, we will support Cocos Studio 2 in v3.3 with a JSON format parser. diff --git a/docs/upgrade-guide-from-3.1-to-3.2.md b/docs/upgrade-guide-from-3.1-to-3.2.md new file mode 100644 index 0000000000..9320d2014b --- /dev/null +++ b/docs/upgrade-guide-from-3.1-to-3.2.md @@ -0,0 +1,127 @@ +#Upgrade guide from Cocos2d-JS v3.1 to Cocos2d-JS v3.2 + +## 0. Upgrade to Cocos2d-JS v3.1 + +If you are still using Cocos2d-html5 or previous version of Cocos2d-JS, you need to read the previous upgrade guide first : [Upgrade guide to Cocos2d-JS v3.1](../../v3.0rc0/upgrade-guide/en.md) + +## 1. Reduce package size with modulirization in JSB + +In Cocos2d-JS v3.2, during compilation, Cocos2d-x modules and related JavaScript Bindings code can be automatically excluded from the final package if they are not used. As you may already know, our web engine support modularization with `modules` section in project.json file. However, this configuration doesn't take effect in JSB, you should do the following to exclude any module you don't need in JSB. + +In AppDelegate.cpp, you will find `applicationDidFinishLaunching` function in which all JSB bindings are registered. If the registration code for a module is commented out, then the base Cocos2d-x module won't be used, during linking the linker will exclude it. This is a common optimization in linker, so it will take effect for both Android and iOS apps. Of course, all modules that you don't register their bindings won't be available in your JavaScript code. + +At last, you only need to compile your project. The minimum size of Android package in Cocos2d-JS v3.2 is 4.4mb. + +``` +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + auto director = Director::getInstance(); + auto glview = director->getOpenGLView(); + if(!glview) { + glview = cocos2d::GLViewImpl::createWithRect("Release3_2", Rect(0,0,900,640)); + director->setOpenGLView(glview); + } + + // set FPS. the default value is 1.0/60 if you don't call this + director->setAnimationInterval(1.0 / 60); + + ScriptingCore* sc = ScriptingCore::getInstance(); + sc->addRegisterCallback(register_all_cocos2dx); + sc->addRegisterCallback(register_cocos2dx_js_core); + sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_system); + + // extension can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + + // chipmunk can be commented out to reduce the package + sc->addRegisterCallback(jsb_register_chipmunk); + // opengl can be commented out to reduce the package + sc->addRegisterCallback(JSB_register_opengl); + + // builder can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_builder); + sc->addRegisterCallback(register_CCBuilderReader); + + // ui can be commented out to reduce the package, attension studio need ui module + sc->addRegisterCallback(register_all_cocos2dx_ui); + sc->addRegisterCallback(register_all_cocos2dx_ui_manual); + + // studio can be commented out to reduce the package, + sc->addRegisterCallback(register_all_cocos2dx_studio); + sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + + // spine can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + + // XmlHttpRequest can be commented out to reduce the package + sc->addRegisterCallback(MinXmlHttpRequest::_js_register); + // websocket can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_websocket); + // sokcet io can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_socketio); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + sc->addRegisterCallback(JavascriptJavaBridge::_js_register); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + sc->addRegisterCallback(JavaScriptObjCBridge::_js_register); +#endif + sc->start(); + sc->runScript("script/jsb_boot.js"); + ScriptEngineProtocol *engine = ScriptingCore::getInstance(); + ScriptEngineManager::getInstance()->setScriptEngine(engine); + ScriptingCore::getInstance()->runScript("main.js"); + + return true; +} +``` + +## 2. Restart game and hot update related APIs + +Since Cocos2d-JS v3.0 Beta, we have provided AssetsManager for assets and scripts hot update ability. Ever since, its stability is greatly improved and become reliable. Thank to our developers, we have also collected many great suggestions and feature requests. In v3.2, we decided to add two importants ones: + +1. Clean a script's cache + + A script will be cached in JSB, so even if you updated it with AssetsManager, it won't take effect even if you require it again. In this case, we provided `cleanScript` API to clean its cache. + + ``` + cc.sys.cleanScript(scriptPath); + ``` + +2. Restart game + + Very often, when the hot update is done, the game need to be restarted entirely. So we provided restart game API, it will do the following steps: + + 1. Clean up Cocos2d-x's environment + 2. Restart the JavaScript VM + 3. Register all script bindings + 4. Re-execute the main.js + + The API is + + ``` + cc.game.restart() + ``` + +3. Manifest's new API: getSearchPaths + + If you want the new JavaScript files updated via AssetsManager to take effect, there are two requirements to be satisfied: + + 1. JavaScript files must be updated correctly. + 2. Everytime before the game start up, the search paths for the new scripts must be prepended before the execution of `cc.game.run()`. Then in `cc.game.run`, the engine will load the updated scripts. + + This means the search paths of the updated assets must be stored locally, so we have provided a new API of Manifest to retrieve the search pahts. Then the local storage can be used to save the search paths, it's our recommended way, but developers can also use whatever they want to save the paths persistantly. Here is an recommended process after the scripts hot update via AssetsManager: + + ``` + // After update succeeded, updated manifest will become the new local manifest. + var searchPaths = assetsManager.getLocalManifest().getSearchPaths(); + // The search paths can be coded to JSON string then stored in cc.sys.localStorage, so that it can be retrieved and preppended to jsb.fileUtils during the game restart. + cc.sys.localStorage.setItem("AssetsSearchPaths", JSON.stringify(searchPaths)); + // Restart the game to let new scripts take effect. + cc.game.restart(); + ``` + +Hope these new APIs will make hot update in your game much eaiser. \ No newline at end of file diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index 2d17e00b23..3e1203d6e1 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit 2d17e00b23a97f4d214a37ba0f54773d4c0eefc9 +Subproject commit 3e1203d6e15d02c15893d28e58e6b2d8905f7616 From f02af3f0964d3fdca046cb3fa23b9feb9bcbcd7b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Dec 2014 16:14:27 +0800 Subject: [PATCH 3/5] Update cocos2d-x for Timeline issue --- frameworks/js-bindings/cocos2d-x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js-bindings/cocos2d-x b/frameworks/js-bindings/cocos2d-x index 5d33292f10..daa4a85447 160000 --- a/frameworks/js-bindings/cocos2d-x +++ b/frameworks/js-bindings/cocos2d-x @@ -1 +1 @@ -Subproject commit 5d33292f107ede90dc4c961968b4c3727d07d929 +Subproject commit daa4a85447b286aaed00c8f7cd8fe4cd7409f211 From 8a84cb09f5e62a17a638561cf40094cc910a903d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Dec 2014 17:01:23 +0800 Subject: [PATCH 4/5] Update submodule --- frameworks/cocos2d-html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index 3e1203d6e1..4d5a2bee39 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit 3e1203d6e15d02c15893d28e58e6b2d8905f7616 +Subproject commit 4d5a2bee39f7abd0e6afc7ece206bb0a8fea912b From f69ac73809804c3b207a5332d118c7149ffa96da Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 29 Dec 2014 17:11:22 +0800 Subject: [PATCH 5/5] Update html5 engine --- frameworks/cocos2d-html5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index 4d5a2bee39..69e72833fa 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit 4d5a2bee39f7abd0e6afc7ece206bb0a8fea912b +Subproject commit 69e72833fab65f11cab93a085e69ccc9e37459b1