diff --git a/cocos2d-x/cocos/audio/AudioEngine.cpp b/cocos2d-x/cocos/audio/AudioEngine.cpp index 588c7010..5913b473 100644 --- a/cocos2d-x/cocos/audio/AudioEngine.cpp +++ b/cocos2d-x/cocos/audio/AudioEngine.cpp @@ -360,6 +360,7 @@ void AudioEngine::onPause(const CustomEvent &event) { if (it->second.state == AudioState::PLAYING) { _audioEngineImpl->pause(it->first); + it->second.state = AudioState::PAUSED; _breakAudioID.push_back(it->first); } } @@ -374,7 +375,12 @@ void AudioEngine::onPause(const CustomEvent &event) { void AudioEngine::onResume(const CustomEvent &event) { auto itEnd = _breakAudioID.end(); for (auto it = _breakAudioID.begin(); it != itEnd; ++it) { - _audioEngineImpl->resume(*it); + auto iter = _audioIDInfoMap.find(*it); + if (iter != _audioIDInfoMap.end() && iter->second.state == AudioState::PAUSED) + { + _audioEngineImpl->resume(*it); + iter->second.state = AudioState::PLAYING; + } } _breakAudioID.clear(); diff --git a/cocos2d-x/cocos/cocos2d.cpp b/cocos2d-x/cocos/cocos2d.cpp index 8d9b7713..b551baff 100644 --- a/cocos2d-x/cocos/cocos2d.cpp +++ b/cocos2d-x/cocos/cocos2d.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "2.4.9"; + return "2.4.10-rc.1"; } NS_CC_END diff --git a/cocos2d-x/cocos/network/WebSocket-libwebsockets.cpp b/cocos2d-x/cocos/network/WebSocket-libwebsockets.cpp index 9de360e4..e9297aab 100644 --- a/cocos2d-x/cocos/network/WebSocket-libwebsockets.cpp +++ b/cocos2d-x/cocos/network/WebSocket-libwebsockets.cpp @@ -853,7 +853,10 @@ void WebSocketImpl::close() void WebSocketImpl::closeAsync(int code, const std::string &reason) { - lws_close_reason(_wsInstance, (lws_close_status)code, (unsigned char*)const_cast(reason.c_str()), reason.length()); + if (_wsInstance) + { + lws_close_reason(_wsInstance, (lws_close_status)code, (unsigned char*)const_cast(reason.c_str()), reason.length()); + } closeAsync(); } diff --git a/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 43827c5d..70fb379e 100644 --- a/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -46,6 +46,7 @@ import android.os.Build; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.Vibrator; +import android.os.LocaleList; import android.preference.PreferenceManager.OnActivityResultListener; import android.util.DisplayMetrics; import android.util.Log; @@ -304,11 +305,19 @@ public class Cocos2dxHelper { } public static String getCurrentLanguage() { - return Locale.getDefault().getLanguage(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return LocaleList.getDefault().get(0).getLanguage(); + } else { + return Locale.getDefault().getLanguage(); + } } public static String getCurrentLanguageCode() { - return Locale.getDefault().toString(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return LocaleList.getDefault().get(0).getLanguage(); + } else { + return Locale.getDefault().getLanguage(); + } } public static String getDeviceModel(){ diff --git a/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket.cpp b/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket.cpp index e09b7071..575f020b 100644 --- a/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket.cpp +++ b/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket.cpp @@ -478,13 +478,32 @@ static bool WebSocket_close(se::State& s) } else if (argc == 2) { - assert(args[0].isNumber()); - assert(args[1].isString()); - int reasonCode; - std::string reasonString; - seval_to_int32(args[0], &reasonCode); - seval_to_std_string(args[1], &reasonString); - cobj->closeAsync(reasonCode, reasonString); + if (args[0].isNumber()) { + int reasonCode; + if (args[1].isString()) { + std::string reasonString; + seval_to_int32(args[0], &reasonCode); + seval_to_std_string(args[1], &reasonString); + cobj->closeAsync(reasonCode, reasonString); + } else if (args[1].isNullOrUndefined()) { + seval_to_int32(args[0], &reasonCode); + cobj->closeAsync(reasonCode, "no_reason"); + } else { + assert(false); + } + } else if (args[0].isNullOrUndefined()) { + if (args[1].isString()) { + std::string reasonString; + seval_to_std_string(args[1], &reasonString); + cobj->closeAsync(1005, reasonString); + } else if (args[1].isNullOrUndefined()) { + cobj->closeAsync(); + } else { + assert(false); + } + } else { + assert(false); + } } else { diff --git a/cocos2d-x/package.json b/cocos2d-x/package.json index 4c88c6f4..3e548cb5 100644 --- a/cocos2d-x/package.json +++ b/cocos2d-x/package.json @@ -1,6 +1,6 @@ { "name": "cocos2d-x-lite", - "version": "2.4.9", + "version": "2.4.10-rc.1", "description": "Cocos2d-x, compact version", "main": "gulpfile.js", "devDependencies": { diff --git a/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml b/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml index 0a990736..b5770593 100755 --- a/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml +++ b/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml @@ -25,7 +25,6 @@ android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" - android:taskAffinity="" android:exported="true"> diff --git a/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java b/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java index 2eb59547..2550d2be 100755 --- a/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java +++ b/cocos2d-x/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java @@ -37,15 +37,6 @@ public class AppActivity extends Cocos2dxActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Workaround in - // https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 - if (!isTaskRoot()) { - // Android launched another instance of the root activity into an existing task - // so just quietly finish and go away, dropping the user back into the activity - // at the top of the stack (ie: the last state of this task) - // Don't need to finish it again since it's finished in super.onCreate . - return; - } // DO OTHER INITIALIZATION BELOW SDKWrapper.getInstance().init(this); diff --git a/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml b/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml index da9874ac..1d92adee 100755 --- a/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml +++ b/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml @@ -25,7 +25,6 @@ android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" - android:taskAffinity="" android:exported="true"> diff --git a/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java b/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java index 2eb59547..2550d2be 100755 --- a/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java +++ b/cocos2d-x/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java @@ -37,15 +37,6 @@ public class AppActivity extends Cocos2dxActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Workaround in - // https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 - if (!isTaskRoot()) { - // Android launched another instance of the root activity into an existing task - // so just quietly finish and go away, dropping the user back into the activity - // at the top of the stack (ie: the last state of this task) - // Don't need to finish it again since it's finished in super.onCreate . - return; - } // DO OTHER INITIALIZATION BELOW SDKWrapper.getInstance().init(this); diff --git a/engine/README.md b/engine/README.md index 43328c9d..06af0884 100644 --- a/engine/README.md +++ b/engine/README.md @@ -148,6 +148,6 @@ For details below: * [Official site](https://www.cocos.com/products#CocosCreator) * [Download](https://www.cocos.com/creator) -* [Documentation](https://docs.cocos.com/creator/manual/) -* [API References](https://docs.cocos.com/creator/api/) +* [Documentation](https://docs.cocos.com/creator/2.4/manual/) +* [API References](https://docs.cocos.com/creator/2.4/api/) * [Forum](https://discuss.cocos2d-x.org/c/creator) diff --git a/engine/api.d.ts b/engine/api.d.ts index e8e3210a..5d10c070 100644 --- a/engine/api.d.ts +++ b/engine/api.d.ts @@ -1,10 +1,21 @@ - -declare let CC_JSB: boolean -declare let CC_NATIVERENDERER: boolean -declare let CC_EDITOR: boolean -declare let CC_PREVIEW: boolean -declare let CC_TEST: boolean -declare let CC_DEBUG: boolean +/** Running in the editor. */ +declare const CC_EDITOR: boolean; +/** Preview in browser or simulator. */ +declare const CC_PREVIEW: boolean; +/** Running in the editor or preview. */ +declare const CC_DEV: boolean; +/** Running in the editor or preview, or build in debug mode. */ +declare const CC_DEBUG: boolean; +/** Running in published project. */ +declare const CC_BUILD: boolean; +/** Running in native platforms (mobile app, desktop app, or simulator). */ +declare const CC_JSB: boolean; +/** Running in runtime environments. */ +declare const CC_RUNTIME: boolean; +/** Running in the engine's unit test. */ +declare const CC_TEST: boolean; +/** Running in the WeChat Mini Game. */ +declare const CC_WECHATGAME: boolean; declare let cc: { // polyfills: { diff --git a/engine/cocos2d/actions/tween.js b/engine/cocos2d/actions/tween.js index 0d947ef7..d3246ab5 100644 --- a/engine/cocos2d/actions/tween.js +++ b/engine/cocos2d/actions/tween.js @@ -218,7 +218,7 @@ Tween.stopAllByTarget = function (target) { * Insert an action or tween to this sequence * !#zh * 插入一个 action 或者 tween 到队列中 - * @method then + * @method then * @param {Action|Tween} other * @return {Tween} * @typescript then(other: Action|Tween): Tween @@ -294,6 +294,7 @@ Tween.prototype.start = function () { Tween.prototype.stop = function () { if (this._finalAction) { cc.director.getActionManager().removeAction(this._finalAction); + this._finalAction = null; } return this; }; @@ -414,7 +415,7 @@ Object.assign(Tween.prototype, { */ flipX () { return this.call(() => { this._target.scaleX *= -1; }, this); - + }, /** * !#en Flips target's scaleY @@ -703,4 +704,4 @@ cc.tween = function (target) { }; cc.Tween = Tween; - + diff --git a/engine/cocos2d/core/CCDirector.js b/engine/cocos2d/core/CCDirector.js index 5178401d..af4739f1 100644 --- a/engine/cocos2d/core/CCDirector.js +++ b/engine/cocos2d/core/CCDirector.js @@ -845,7 +845,7 @@ cc.Director.prototype = { // Update if (!this._paused) { - this.emit(cc.Director.EVENT_BEFORE_UPDATE); + this.emit(cc.Director.EVENT_BEFORE_UPDATE, deltaTime); this._compScheduler.startPhase(); this._compScheduler.updatePhase(deltaTime); @@ -856,15 +856,15 @@ cc.Director.prototype = { this._compScheduler.lateUpdatePhase(deltaTime); - this.emit(cc.Director.EVENT_AFTER_UPDATE); + this.emit(cc.Director.EVENT_AFTER_UPDATE, deltaTime); } // Render - this.emit(cc.Director.EVENT_BEFORE_DRAW); + this.emit(cc.Director.EVENT_BEFORE_DRAW, deltaTime); renderer.render(this._scene, deltaTime); // After draw - this.emit(cc.Director.EVENT_AFTER_DRAW); + this.emit(cc.Director.EVENT_AFTER_DRAW, deltaTime); this._totalFrames++; @@ -877,35 +877,36 @@ cc.Director.prototype = { // calculate "global" dt this.calculateDeltaTime(now); + const deltaTime = this._deltaTime; // Update if (!this._paused) { // before update - this.emit(cc.Director.EVENT_BEFORE_UPDATE); + this.emit(cc.Director.EVENT_BEFORE_UPDATE, deltaTime); // Call start for new added components this._compScheduler.startPhase(); // Update for components - this._compScheduler.updatePhase(this._deltaTime); + this._compScheduler.updatePhase(deltaTime); // Engine update with scheduler - this._scheduler.update(this._deltaTime); + this._scheduler.update(deltaTime); // Late update for components - this._compScheduler.lateUpdatePhase(this._deltaTime); + this._compScheduler.lateUpdatePhase(deltaTime); // User can use this event to do things after update - this.emit(cc.Director.EVENT_AFTER_UPDATE); + this.emit(cc.Director.EVENT_AFTER_UPDATE, deltaTime); // Destroy entities that have been removed recently Obj._deferredDestroy(); } // Render - this.emit(cc.Director.EVENT_BEFORE_DRAW); - renderer.render(this._scene, this._deltaTime); + this.emit(cc.Director.EVENT_BEFORE_DRAW, deltaTime); + renderer.render(this._scene, deltaTime); // After draw - this.emit(cc.Director.EVENT_AFTER_DRAW); + this.emit(cc.Director.EVENT_AFTER_DRAW, deltaTime); eventManager.frameUpdateListeners(); this._totalFrames++; diff --git a/engine/cocos2d/core/asset-manager/cache-manager.ts b/engine/cocos2d/core/asset-manager/cache-manager.ts index c1bb9876..5577867b 100644 --- a/engine/cocos2d/core/asset-manager/cache-manager.ts +++ b/engine/cocos2d/core/asset-manager/cache-manager.ts @@ -149,6 +149,7 @@ export abstract class CacheManager { * 通过原始 url 移除缓存 * * @method removeCache + * @param {string} originUrl */ public abstract removeCache (originUrl: string): void; } diff --git a/engine/cocos2d/core/asset-manager/deprecated.js b/engine/cocos2d/core/asset-manager/deprecated.js index e94d779a..1d85b4d5 100644 --- a/engine/cocos2d/core/asset-manager/deprecated.js +++ b/engine/cocos2d/core/asset-manager/deprecated.js @@ -677,7 +677,7 @@ Object.defineProperties(cc, { if (CC_DEBUG) { if (onceWarns.loader) { onceWarns.loader = false; - cc.log('cc.loader is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/manual/zh/release-notes/asset-manager-upgrade-guide.html'); + cc.log('cc.loader is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/2.4/manual/zh/release-notes/asset-manager-upgrade-guide.html'); } } return loader; diff --git a/engine/cocos2d/core/assets/CCSpriteFrame.js b/engine/cocos2d/core/assets/CCSpriteFrame.js index 61b1263f..efee970f 100644 --- a/engine/cocos2d/core/assets/CCSpriteFrame.js +++ b/engine/cocos2d/core/assets/CCSpriteFrame.js @@ -383,11 +383,11 @@ let SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{ } if (!self._originalSize) { - self.setOriginalSize(cc.size(w, h)); + self._originalSize = cc.size(w, h); } if (!self._offset) { - self.setOffset(cc.v2(0, 0)); + self._offset = cc.v2(0, 0); } self._calculateUV(); diff --git a/engine/cocos2d/core/components/CCLabel.js b/engine/cocos2d/core/components/CCLabel.js index 1630a4b3..2404005a 100644 --- a/engine/cocos2d/core/components/CCLabel.js +++ b/engine/cocos2d/core/components/CCLabel.js @@ -674,6 +674,18 @@ let Label = cc.Class({ this._super(); }, + onRestore: CC_EDITOR && function () { + // Because undo/redo will not call onEnable/onDisable, + // we need call onEnable/onDisable manually to active/disactive children nodes. + if (this.enabledInHierarchy) { + this.node._renderComponent = null; + this.onEnable(); + } + else { + this.onDisable(); + } + }, + _nodeSizeChanged () { // Because the content size is automatically updated when overflow is NONE. // And this will conflict with the alignment of the CCWidget. diff --git a/engine/cocos2d/core/components/CCMotionStreak.js b/engine/cocos2d/core/components/CCMotionStreak.js index a2fb140a..df3cd99c 100644 --- a/engine/cocos2d/core/components/CCMotionStreak.js +++ b/engine/cocos2d/core/components/CCMotionStreak.js @@ -62,6 +62,7 @@ var MotionStreak = cc.Class({ ctor () { this._points = []; this._lastWPos = new cc.Vec2(); + this._lastWPosUpdated = false; }, properties: { @@ -313,8 +314,7 @@ var MotionStreak = cc.Class({ reset () { this._points.length = 0; this._assembler && this._assembler._renderData.clear(); - this._lastWPos.x = 0; - this._lastWPos.y = 0; + this._lastWPosUpdated = false; if (CC_EDITOR) { cc.engine.repaintInEditMode(); } diff --git a/engine/cocos2d/core/physics/CCPolygonSeparator.js b/engine/cocos2d/core/physics/CCPolygonSeparator.js index 036f7c8d..06c997c9 100644 --- a/engine/cocos2d/core/physics/CCPolygonSeparator.js +++ b/engine/cocos2d/core/physics/CCPolygonSeparator.js @@ -68,14 +68,14 @@ function ConvexPartition(vertices) { var list = []; var d, lowerDist, upperDist; var p; - var lowerInt = cc.v2(); - var upperInt = cc.v2(); // intersection points + var lowerInt = null; + var upperInt = null; // intersection points var lowerIndex = 0, upperIndex = 0; var lowerPoly, upperPoly; for (var i = 0; i < vertices.length; ++i) { if (Reflex(i, vertices)) { - lowerDist = upperDist = 10e7; // std::numeric_limits::max(); + lowerDist = upperDist = Number.MAX_SAFE_INTEGER || 9999999999999; // std::numeric_limits::max(); for (var j = 0; j < vertices.length; ++j) { // if line intersects with an edge if (Left(At(i - 1, vertices), At(i, vertices), At(j, vertices)) && diff --git a/engine/cocos2d/core/platform/CCMacro.js b/engine/cocos2d/core/platform/CCMacro.js index 037ee54a..d277c1d3 100644 --- a/engine/cocos2d/core/platform/CCMacro.js +++ b/engine/cocos2d/core/platform/CCMacro.js @@ -316,12 +316,12 @@ cc.macro = { /** * !#en - * Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + * Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. * Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. * But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. * So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. * !#zh - * 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + * 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。 * 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。 * 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 * 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。 diff --git a/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js b/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js index ecaf5558..801337a6 100644 --- a/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js +++ b/engine/cocos2d/core/renderer/utils/dynamic-atlas/manager.js @@ -32,8 +32,8 @@ function beforeSceneLoad() { let _enabled = false; /** - * !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. - * !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + * !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details. + * !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。 * @class DynamicAtlasManager */ let dynamicAtlasManager = { @@ -41,8 +41,8 @@ let dynamicAtlasManager = { Rect: Rect, /** - * !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details. - * !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + * !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details. + * !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。 * @property enabled * @type {Boolean} */ @@ -192,6 +192,7 @@ let dynamicAtlasManager = { * !#zh 添加碎图进入动态图集。 * @method insertSpriteFrame * @param {SpriteFrame} spriteFrame + * @return {Object} frame */ insertSpriteFrame(spriteFrame) { if (CC_EDITOR) return null; diff --git a/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak-multi.js b/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak-multi.js index 98141b32..5c345578 100644 --- a/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak-multi.js +++ b/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak-multi.js @@ -25,6 +25,8 @@ import MotionStreakAssembler from "./motion-streak"; import { vfmtPosUvColorTexId } from '../../webgl/vertex-format'; +import Mat4 from '../../../value-types/mat4'; + const MotionStreak = require('../../../components/CCMotionStreak'); const RenderFlow = require('../../render-flow'); @@ -47,6 +49,7 @@ Point.prototype.setDir = function (x, y) { let _normal = cc.v2(); let _vec2 = cc.v2(); +let _worldMat = new Mat4(); function normal (out, dir) { //get perpendicular @@ -74,14 +77,14 @@ export default class MultiMotionStreakAssembler extends MotionStreakAssembler { let stroke = comp._stroke / 2; let node = comp.node; - let matrix = node._worldMatrix.m; - let tx = matrix[12], ty = matrix[13]; + node.getWorldMatrix(_worldMat); + let tx = _worldMat.m[12], ty = _worldMat.m[13]; let points = comp._points; let lastPos = comp._lastWPos; let fadeTime = comp._fadeTime; - let moved = lastPos.x !== tx || lastPos.y !== ty; + let moved = comp._lastWPosUpdated && (lastPos.x !== tx || lastPos.y !== ty); if (moved) { let cur; let newHead = false; @@ -126,7 +129,8 @@ export default class MultiMotionStreakAssembler extends MotionStreakAssembler { lastPos.x = tx; lastPos.y = ty; - + comp._lastWPosUpdated = true; + if (points.length < 2) { return; } diff --git a/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak.js b/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak.js index b15433c6..477ca7ea 100644 --- a/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak.js +++ b/engine/cocos2d/core/renderer/webgl/assemblers/motion-streak.js @@ -24,6 +24,7 @@ ****************************************************************************/ import Assembler2D from '../../assembler-2d'; +import Mat4 from '../../../value-types/mat4'; const RenderFlow = require('../../render-flow'); @@ -48,6 +49,7 @@ let _tangent = cc.v2(); let _miter = cc.v2(); let _normal = cc.v2(); let _vec2 = cc.v2(); +let _worldMat = new Mat4(); function normal (out, dir) { //get perpendicular @@ -91,14 +93,14 @@ export default class MotionStreakAssembler extends Assembler2D { let stroke = comp._stroke / 2; let node = comp.node; - let matrix = node._worldMatrix.m; - let tx = matrix[12], ty = matrix[13]; + node.getWorldMatrix(_worldMat); + let tx = _worldMat.m[12], ty = _worldMat.m[13]; let points = comp._points; let lastPos = comp._lastWPos; let fadeTime = comp._fadeTime; - let moved = lastPos.x !== tx || lastPos.y !== ty; + let moved = comp._lastWPosUpdated && (lastPos.x !== tx || lastPos.y !== ty); if (moved) { let cur; let newHead = false; @@ -143,7 +145,8 @@ export default class MotionStreakAssembler extends Assembler2D { lastPos.x = tx; lastPos.y = ty; - + comp._lastWPosUpdated = true; + if (points.length < 2) { return; } diff --git a/engine/cocos2d/particle/CCParticleSystem.js b/engine/cocos2d/particle/CCParticleSystem.js index f063ad26..a4f28fbe 100644 --- a/engine/cocos2d/particle/CCParticleSystem.js +++ b/engine/cocos2d/particle/CCParticleSystem.js @@ -820,6 +820,18 @@ var ParticleSystem = cc.Class({ } }, + onRestore: CC_EDITOR && function () { + // Because undo/redo will not call onEnable/onDisable, + // we need call onEnable/onDisable manually to active/disactive children nodes. + if (this.enabledInHierarchy) { + this.node._renderComponent = null; + this.onEnable(); + } + else { + this.onDisable(); + } + }, + _startPreview: CC_EDITOR && function () { if (this.preview) { this.resetSystem(); diff --git a/engine/editor/i18n/en/localization.js b/engine/editor/i18n/en/localization.js index 6972d7cb..a28187a6 100755 --- a/engine/editor/i18n/en/localization.js +++ b/engine/editor/i18n/en/localization.js @@ -1,33 +1,33 @@ module.exports = { 'COMPONENT': { "help_url": { - "audiosource": "https://docs.cocos.com/creator/manual/en/components/audiosource.html", - "animation": "https://docs.cocos.com/creator/manual/en/components/animation.html", - "sprite": "https://docs.cocos.com/creator/manual/en/components/sprite.html", - "label": "https://docs.cocos.com/creator/manual/en/components/label.html", - "canvas": "https://docs.cocos.com/creator/manual/en/components/canvas.html", - "spine": "https://docs.cocos.com/creator/manual/en/components/spine.html", - "widget": "https://docs.cocos.com/creator/manual/en/components/widget.html", - "button": "https://docs.cocos.com/creator/manual/en/components/button.html", - "progressbar": "https://docs.cocos.com/creator/manual/en/components/progress.html", - "mask": "https://docs.cocos.com/creator/manual/en/components/mask.html", - "scrollview": "https://docs.cocos.com/creator/manual/en/components/scrollview.html", - "scrollbar": "https://docs.cocos.com/creator/manual/en/components/scrollbar.html", - "layout": "https://docs.cocos.com/creator/manual/en/components/layout.html", - "tiledmap": "https://docs.cocos.com/creator/manual/en/components/tiledmap.html", - "editbox": "https://docs.cocos.com/creator/manual/en/components/editbox.html", - "videoplayer": "https://docs.cocos.com/creator/manual/en/components/videoplayer.html", - "motionStreak": "https://docs.cocos.com/creator/manual/en/components/motion-streak.html", - "richtext": "https://docs.cocos.com/creator/manual/en/components/richtext.html", - "pageview": "https://docs.cocos.com/creator/manual/en/components/pageview.html", - "pageviewIndicator": "https://docs.cocos.com/creator/manual/en/components/pageviewindicator.html", - "toggle": "https://docs.cocos.com/creator/manual/en/components/toggle.html", - "toggleGroup": "https://docs.cocos.com/creator/manual/en/components/toggleGroup.html", - "toggleContainer": "https://docs.cocos.com/creator/manual/en/components/toggleContainer.html", - "slider": "https://docs.cocos.com/creator/manual/en/components/slider.html", - "block_input_events": "https://docs.cocos.com/creator/manual/en/components/block-input-events.html", - "subcontext_view": "https://docs.cocos.com/creator/manual/en/publish/publish-wechatgame-sub-domain.html", - "safe_area": "https://docs.cocos.com/creator/manual/en/components/safearea.html" + "audiosource": "https://docs.cocos.com/creator/2.4/manual/en/components/audiosource.html", + "animation": "https://docs.cocos.com/creator/2.4/manual/en/components/animation.html", + "sprite": "https://docs.cocos.com/creator/2.4/manual/en/components/sprite.html", + "label": "https://docs.cocos.com/creator/2.4/manual/en/components/label.html", + "canvas": "https://docs.cocos.com/creator/2.4/manual/en/components/canvas.html", + "spine": "https://docs.cocos.com/creator/2.4/manual/en/components/spine.html", + "widget": "https://docs.cocos.com/creator/2.4/manual/en/components/widget.html", + "button": "https://docs.cocos.com/creator/2.4/manual/en/components/button.html", + "progressbar": "https://docs.cocos.com/creator/2.4/manual/en/components/progress.html", + "mask": "https://docs.cocos.com/creator/2.4/manual/en/components/mask.html", + "scrollview": "https://docs.cocos.com/creator/2.4/manual/en/components/scrollview.html", + "scrollbar": "https://docs.cocos.com/creator/2.4/manual/en/components/scrollbar.html", + "layout": "https://docs.cocos.com/creator/2.4/manual/en/components/layout.html", + "tiledmap": "https://docs.cocos.com/creator/2.4/manual/en/components/tiledmap.html", + "editbox": "https://docs.cocos.com/creator/2.4/manual/en/components/editbox.html", + "videoplayer": "https://docs.cocos.com/creator/2.4/manual/en/components/videoplayer.html", + "motionStreak": "https://docs.cocos.com/creator/2.4/manual/en/components/motion-streak.html", + "richtext": "https://docs.cocos.com/creator/2.4/manual/en/components/richtext.html", + "pageview": "https://docs.cocos.com/creator/2.4/manual/en/components/pageview.html", + "pageviewIndicator": "https://docs.cocos.com/creator/2.4/manual/en/components/pageviewindicator.html", + "toggle": "https://docs.cocos.com/creator/2.4/manual/en/components/toggle.html", + "toggleGroup": "https://docs.cocos.com/creator/2.4/manual/en/components/toggleGroup.html", + "toggleContainer": "https://docs.cocos.com/creator/2.4/manual/en/components/toggleContainer.html", + "slider": "https://docs.cocos.com/creator/2.4/manual/en/components/slider.html", + "block_input_events": "https://docs.cocos.com/creator/2.4/manual/en/components/block-input-events.html", + "subcontext_view": "https://docs.cocos.com/creator/2.4/manual/en/publish/publish-wechatgame-sub-domain.html", + "safe_area": "https://docs.cocos.com/creator/2.4/manual/en/components/safearea.html" }, "animation": { "default_clip": "When checking, the deault animation clip is automatically played.", diff --git a/engine/editor/i18n/zh/localization.js b/engine/editor/i18n/zh/localization.js index 18de7d07..5d8ba326 100755 --- a/engine/editor/i18n/zh/localization.js +++ b/engine/editor/i18n/zh/localization.js @@ -1,33 +1,33 @@ module.exports = { 'COMPONENT': { "help_url": { - "audiosource": "https://docs.cocos.com/creator/manual/zh/components/audiosource.html", - "animation": "https://docs.cocos.com/creator/manual/zh/components/animation.html", - "sprite": "https://docs.cocos.com/creator/manual/zh/components/sprite.html", - "label": "https://docs.cocos.com/creator/manual/zh/components/label.html", - "canvas": "https://docs.cocos.com/creator/manual/zh/components/canvas.html", - "spine": "https://docs.cocos.com/creator/manual/zh/components/spine.html", - "widget": "https://docs.cocos.com/creator/manual/zh/components/widget.html", - "button": "https://docs.cocos.com/creator/manual/zh/components/button.html", - "progressbar": "https://docs.cocos.com/creator/manual/zh/components/progress.html", - "mask": "https://docs.cocos.com/creator/manual/zh/components/mask.html", - "scrollview": "https://docs.cocos.com/creator/manual/zh/components/scrollview.html", - "scrollbar": "https://docs.cocos.com/creator/manual/zh/components/scrollbar.html", - "layout": "https://docs.cocos.com/creator/manual/zh/components/layout.html", - "tiledmap": "https://docs.cocos.com/creator/manual/zh/components/tiledmap.html", - "editbox": "https://docs.cocos.com/creator/manual/zh/components/editbox.html", - "videoplayer": "https://docs.cocos.com/creator/manual/zh/components/videoplayer.html", - "motionStreak": "https://docs.cocos.com/creator/manual/zh/components/motion-streak.html", - "richtext": "https://docs.cocos.com/creator/manual/zh/components/richtext.html", - "pageview": "https://docs.cocos.com/creator/manual/zh/components/pageview.html", - "pageviewIndicator": "https://docs.cocos.com/creator/manual/zh/components/pageviewindicator.html", - "toggle": "https://docs.cocos.com/creator/manual/zh/components/toggle.html", - "toggleGroup": "https://docs.cocos.com/creator/manual/zh/components/toggleGroup.html", - "toggleContainer": "https://docs.cocos.com/creator/manual/zh/components/toggleContainer.html", - "slider": "https://docs.cocos.com/creator/manual/zh/components/slider.html", - "block_input_events": "https://docs.cocos.com/creator/manual/zh/components/block-input-events.html", - "subcontext_view": "https://docs.cocos.com/creator/manual/zh/publish/publish-wechatgame-sub-domain.html", - "safe_area": "https://docs.cocos.com/creator/manual/zh/components/safearea.html", + "audiosource": "https://docs.cocos.com/creator/2.4/manual/zh/components/audiosource.html", + "animation": "https://docs.cocos.com/creator/2.4/manual/zh/components/animation.html", + "sprite": "https://docs.cocos.com/creator/2.4/manual/zh/components/sprite.html", + "label": "https://docs.cocos.com/creator/2.4/manual/zh/components/label.html", + "canvas": "https://docs.cocos.com/creator/2.4/manual/zh/components/canvas.html", + "spine": "https://docs.cocos.com/creator/2.4/manual/zh/components/spine.html", + "widget": "https://docs.cocos.com/creator/2.4/manual/zh/components/widget.html", + "button": "https://docs.cocos.com/creator/2.4/manual/zh/components/button.html", + "progressbar": "https://docs.cocos.com/creator/2.4/manual/zh/components/progress.html", + "mask": "https://docs.cocos.com/creator/2.4/manual/zh/components/mask.html", + "scrollview": "https://docs.cocos.com/creator/2.4/manual/zh/components/scrollview.html", + "scrollbar": "https://docs.cocos.com/creator/2.4/manual/zh/components/scrollbar.html", + "layout": "https://docs.cocos.com/creator/2.4/manual/zh/components/layout.html", + "tiledmap": "https://docs.cocos.com/creator/2.4/manual/zh/components/tiledmap.html", + "editbox": "https://docs.cocos.com/creator/2.4/manual/zh/components/editbox.html", + "videoplayer": "https://docs.cocos.com/creator/2.4/manual/zh/components/videoplayer.html", + "motionStreak": "https://docs.cocos.com/creator/2.4/manual/zh/components/motion-streak.html", + "richtext": "https://docs.cocos.com/creator/2.4/manual/zh/components/richtext.html", + "pageview": "https://docs.cocos.com/creator/2.4/manual/zh/components/pageview.html", + "pageviewIndicator": "https://docs.cocos.com/creator/2.4/manual/zh/components/pageviewindicator.html", + "toggle": "https://docs.cocos.com/creator/2.4/manual/zh/components/toggle.html", + "toggleGroup": "https://docs.cocos.com/creator/2.4/manual/zh/components/toggleGroup.html", + "toggleContainer": "https://docs.cocos.com/creator/2.4/manual/zh/components/toggleContainer.html", + "slider": "https://docs.cocos.com/creator/2.4/manual/zh/components/slider.html", + "block_input_events": "https://docs.cocos.com/creator/2.4/manual/zh/components/block-input-events.html", + "subcontext_view": "https://docs.cocos.com/creator/2.4/manual/zh/publish/publish-wechatgame-sub-domain.html", + "safe_area": "https://docs.cocos.com/creator/2.4/manual/zh/components/safearea.html", }, 'animation': { 'default_clip': '在勾选自动播放或调用 play() 时默认播放的动画 clip。', diff --git a/engine/package.json b/engine/package.json index b174ca46..9d5cd85a 100644 --- a/engine/package.json +++ b/engine/package.json @@ -1,6 +1,6 @@ { "name": "cocos-creator-js", - "version": "2.4.9", + "version": "2.4.10", "description": "Cocos Creator is a complete package of game development tools and workflow, including a game engine, resource management, scene editing, game preview, debug and publish one project to multiple platforms.", "homepage": "https://www.cocos.com", "license": "MIT", diff --git a/engine/predefine.js b/engine/predefine.js index a385b894..1d6e9458 100644 --- a/engine/predefine.js +++ b/engine/predefine.js @@ -132,7 +132,7 @@ function defineDeprecatedMacroGetter (name, defaultValue) { recommandedUsage = 'cc.sys.platform === cc.sys.WECHAT_GAME_SUB'; } else if (name === 'CC_WECHATGAME') { - recommandedUsage = 'cc.sys.platform === cc.sys.WECHAT_GAME'; + recommandedUsage = 'cc.sys.platform === cc.sys.WECHAT_GAME'; } else if (name === 'CC_QQPLAY') { recommandedUsage = 'cc.sys.platform === cc.sys.QQ_PLAY'; @@ -185,7 +185,7 @@ else { defineMacro('CC_JSB', defined('jsb') && !CC_RUNTIME); } -// deprecated +// deprecated const WECHATGAMESUB = !!(defined('wx') && wx.getSharedCanvas); const WECHATGAME = !!(defined('wx') && (wx.getSystemInfoSync || wx.getSharedCanvas)); const QQPLAY = defined('bk'); @@ -211,5 +211,5 @@ if (CC_DEV) { * If you post a bug to forum, please attach this flag. * @property {String} ENGINE_VERSION */ -const engineVersion = '2.4.9'; +const engineVersion = '2.4.10'; _global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion; diff --git a/jsb-adapter/engine/assemblers/motion-streak-multi.js b/jsb-adapter/engine/assemblers/motion-streak-multi.js index 1df4efc6..a42d3ec3 100644 --- a/jsb-adapter/engine/assemblers/motion-streak-multi.js +++ b/jsb-adapter/engine/assemblers/motion-streak-multi.js @@ -3,8 +3,6 @@ let proto = cc.MotionStreak.__assembler__.MultiMotionStreakAssembler.prototype; let _update = proto.update; cc.js.mixin(proto, { update (comp, dt) { - comp.node._updateWorldMatrix(); - _update.call(this, comp, dt); let { iData, usedVertices } = this._renderData._flexBuffer; diff --git a/jsb-adapter/engine/assemblers/motion-streak.js b/jsb-adapter/engine/assemblers/motion-streak.js index 8ad9648a..fd076c06 100644 --- a/jsb-adapter/engine/assemblers/motion-streak.js +++ b/jsb-adapter/engine/assemblers/motion-streak.js @@ -11,8 +11,6 @@ cc.js.mixin(proto, { this.ignoreOpacityFlag(); }, update (comp, dt) { - comp.node._updateWorldMatrix(); - _update.call(this, comp, dt); let { iData, usedVertices } = this._renderData._flexBuffer;