From 81f35845fc2c7f6c04936b764671956578e9afad Mon Sep 17 00:00:00 2001 From: Knox Date: Wed, 23 May 2018 10:00:59 +0800 Subject: [PATCH 1/7] Improve checking whether is a subdomain method (#2719) --- cocos2d/core/platform/CCSys.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js index f26fab9100..36eb387316 100644 --- a/cocos2d/core/platform/CCSys.js +++ b/cocos2d/core/platform/CCSys.js @@ -576,7 +576,7 @@ else if (CC_WECHATGAME) { sys.osVersion = version[0]; sys.osMainVersion = parseInt(sys.osVersion); // wechagame subdomain - if (wx.getGroupCloudStorage && wx.getFriendCloudStorage) { + if (!wx.getFileSystemManager) { sys.browserType = sys.BROWSER_TYPE_WECHAT_GAME_SUB; } else { From c951d8c620fc7d89a9e42fd77a75e69d72945ede Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Fri, 25 May 2018 13:51:12 +0800 Subject: [PATCH 2/7] VideoPlayer should accpet asset object (#2722) --- cocos2d/core/components/CCVideoPlayer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js index 50e16995f9..13b9f972b5 100644 --- a/cocos2d/core/components/CCVideoPlayer.js +++ b/cocos2d/core/components/CCVideoPlayer.js @@ -155,8 +155,11 @@ var VideoPlayer = cc.Class({ return this._clip; }, set: function (value) { - if (typeof value !== 'string') - value = ''; + if (typeof value === 'string') { + // backward compatibility since 1.10 + cc.errorID(8401, 'cc.VideoPlayer', 'cc.Asset', 'Asset', 'cc.Asset', 'video'); + value = { nativeUrl: value }; + } this._clip = value; this._updateVideoSource(); }, From 2b35813c26a94e20e7295ed3c31f4e7534cd3fab Mon Sep 17 00:00:00 2001 From: Knox Date: Fri, 25 May 2018 18:19:10 +0800 Subject: [PATCH 3/7] fix fireball/issues/7368 (#2743) --- cocos2d/core/components/CCScrollView.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 83268bc67d..c8af85c20b 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -1245,8 +1245,8 @@ var ScrollView = cc.Class({ this._autoScrolling = false; } - var contentPos = cc.pSub(newPosition, this.getContentPosition()); - this._moveContent(contentPos, reachedEnd); + var deltaMove = cc.pSub(newPosition, this.getContentPosition()); + this._moveContent(this._clampDelta(deltaMove), reachedEnd); this._dispatchEvent('scrolling'); if (!this._autoScrolling) { @@ -1334,7 +1334,6 @@ var ScrollView = cc.Class({ this._autoScrollBraking = true; } } - }, _calculateTouchMoveVelocity: function() { @@ -1365,7 +1364,6 @@ var ScrollView = cc.Class({ _moveContent: function(deltaMove, canStartBounceBack) { var adjustedMove = this._flattenVectorByDirection(deltaMove); - var newPosition = cc.pAdd(this.getContentPosition(), adjustedMove); this.setContentPosition(newPosition); @@ -1376,10 +1374,8 @@ var ScrollView = cc.Class({ if (this.elastic && canStartBounceBack) { this._startBounceBackIfNeeded(); } - }, - _getContentLeftBoundary: function() { var contentPos = this.getContentPosition(); var leftBoundary = contentPos.x - this.content.getAnchorPoint().x * this.content.getContentSize().width; From 9029fe04470d229b0950b2e60df377a0d1aa6d8b Mon Sep 17 00:00:00 2001 From: Knox Date: Sun, 27 May 2018 23:00:25 +0800 Subject: [PATCH 4/7] fix fireball/issues/7369 (#2741) --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index c6415d251c..3208376d92 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -201,7 +201,7 @@ Audio.State = { }; proto.resume = function () { - if (!this._element || this._element.currentTime === 0) return; + if (!this._element || this._state === Audio.State.PLAYING) return; this._bindEnded(); this._element.play(); this.emit('resume'); From 92e99f303812a8ac16f67a3cee9fc1f7cddf8682 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 29 May 2018 09:27:29 +0800 Subject: [PATCH 5/7] new instantiated nodes should clean it's fileId before adding to other prefabs. (#2753) --- cocos2d/core/utils/base-node.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index dc89a26618..0f68ae49c1 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -1107,8 +1107,11 @@ var BaseNode = cc.Class({ var myPrefabInfo = this._prefab; if (myPrefabInfo) { if (newPrefabRoot) { - // change prefab - _Scene.PrefabUtils.linkPrefab(newPrefabRoot._prefab.asset, newPrefabRoot, this); + if (myPrefabInfo.root !== newPrefabRoot) { + // change prefab + _Scene.PrefabUtils.unlinkPrefab(this); + _Scene.PrefabUtils.linkPrefab(newPrefabRoot._prefab.asset, newPrefabRoot, this); + } } else if (myPrefabInfo.root !== this) { // detach from prefab From 9e8e43c2ff7ccf8de49f62b48c764c7b40ac8faa Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 29 May 2018 10:02:02 +0800 Subject: [PATCH 6/7] pause animation playing when unenabled (#2718) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add animation warn id fix animation bug 添加注释 英文注释 --- cocos2d/core/components/CCAnimation.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos2d/core/components/CCAnimation.js b/cocos2d/core/components/CCAnimation.js index a0e7d47a21..95c1fc4674 100644 --- a/cocos2d/core/components/CCAnimation.js +++ b/cocos2d/core/components/CCAnimation.js @@ -262,6 +262,14 @@ var Animation = cc.Class({ animator.playState(state, startTime); } + // Animation cannot be played when the component is not enabledInHierarchy. + // That would cause an error for the animation lost the reference after destroying the node. + // If users play the animation when the component is not enabledInHierarchy, + // we pause the animator here so that it will automatically resume the animation when users enable the component. + if (!this.enabledInHierarchy) { + animator.pause(); + } + this.currentClip = state.clip; } return state; From 6fc2df6f89d1e21122bf2a4c6b5fb9927896a7a0 Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 29 May 2018 15:10:54 +0800 Subject: [PATCH 7/7] simplify audioEngine resume (#2752) --- cocos2d/audio/CCAudioEngine.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cocos2d/audio/CCAudioEngine.js b/cocos2d/audio/CCAudioEngine.js index 828417a0f7..08f118f5ed 100644 --- a/cocos2d/audio/CCAudioEngine.js +++ b/cocos2d/audio/CCAudioEngine.js @@ -329,11 +329,8 @@ var audioEngine = { var audio = getAudioFromId(audioID); if (!audio || !audio.resume) return false; - if (audio.getCurrentTime() === 0) { - audio.play(); - } else { - audio.resume(); - } + + audio.resume(); }, /**