From 1116f8e9d2f5dbff9c1c9d741e39863f91719657 Mon Sep 17 00:00:00 2001
From: knox
Date: Wed, 2 May 2018 16:32:28 +0800
Subject: [PATCH 01/35] =?UTF-8?q?Fix=20qqplay=20Blue=20Screen=20bug=20when?=
=?UTF-8?q?=20ios=20version=20is=20less=20than=2010=EF=BC=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
cocos2d/core/platform/CCSys.js | 21 +++++++++++++++------
cocos2d/core/renderer/RendererWebGL.js | 19 +++++++++++++++++--
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index 4cd272a029..86661c14cc 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -598,20 +598,29 @@ else if (CC_WECHATGAME) {
};
}
else if (CC_QQPLAY) {
+ var env = window["BK"]["Director"]["queryDeviceInfo"]();
sys.isMobile = true;
sys.platform = sys.QQ_PLAY;
sys.language = sys.LANGUAGE_UNKNOWN;
- sys.os = sys.OS_UNKNOWN;
+ if (env.platform === "android") {
+ sys.os = sys.OS_ANDROID;
+ }
+ else if (env.platform === "ios") {
+ sys.os = sys.OS_IOS;
+ }
+ else {
+ sys.os = sys.OS_UNKNOWN;
+ }
- sys.osVersion = 0;
+ var version = /[\d\.]+/.exec(env.version);
+ sys.osVersion = version[0];
sys.osMainVersion = 0;
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
sys.browserVersion = 0;
- var w = 960;
- var h = 640;
- var ratio = 1;
-
+ var w = env.screenWidth;
+ var h = env.screenHeight;
+ var ratio = env.pixelRatio || 1;
sys.windowPixelResolution = {
width: ratio * w,
height: ratio * h
diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js
index ecdd999c75..e1f9baec79 100644
--- a/cocos2d/core/renderer/RendererWebGL.js
+++ b/cocos2d/core/renderer/RendererWebGL.js
@@ -143,6 +143,12 @@ cc.rendererWebGL = {
initQuadBuffer(cc.macro.BATCH_VERTEX_COUNT);
if (cc.sys.os === cc.sys.OS_IOS) {
_IS_IOS = true;
+
+ // todo Can be removed after qqplay with support
+ let version = cc.sys.osVersion.split('.');
+ if (cc.sys.platform === cc.sys.QQ_PLAY && version[0] < 10) {
+ cc.sys.isOldIOS = true;
+ }
}
},
@@ -438,11 +444,20 @@ cc.rendererWebGL = {
gl.bindBuffer(gl.ARRAY_BUFFER, _vertexBuffer);
// upload the vertex data to the gl buffer
if (uploadAll) {
- gl.bufferData(gl.ARRAY_BUFFER, _vertexDataF32, gl.DYNAMIC_DRAW);
+ if (cc.sys.isOldIOS) {
+ gl.bufferDataOldIOS(gl.ARRAY_BUFFER, _vertexDataF32, _vertexDataUI32, gl.DYNAMIC_DRAW);
+ }
+ else
+ gl.bufferData(gl.ARRAY_BUFFER, _vertexDataF32, gl.DYNAMIC_DRAW);
}
else {
var view = _vertexDataF32.subarray(0, _batchingSize * _sizePerVertex);
- gl.bufferData(gl.ARRAY_BUFFER, view, gl.DYNAMIC_DRAW);
+ if (cc.sys.isOldIOS) {
+ var viewUI32 = _vertexDataUI32.subarray(0, _batchingSize * _sizePerVertex);
+ gl.bufferDataOldIOS(gl.ARRAY_BUFFER, view, viewUI32, gl.DYNAMIC_DRAW);
+ }
+ else
+ gl.bufferData(gl.ARRAY_BUFFER, view, gl.DYNAMIC_DRAW);
}
gl.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION);
From 70bf3e325bcfdbe35219303b81e8eb4bb6347a16 Mon Sep 17 00:00:00 2001
From: knox
Date: Wed, 2 May 2018 17:45:35 +0800
Subject: [PATCH 02/35] fix layout newChildWidth bug for
cocos-creator/engine/issues/2383
---
cocos2d/core/components/CCLayout.js | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js
index 7315b320d4..be07bcfdb0 100644
--- a/cocos2d/core/components/CCLayout.js
+++ b/cocos2d/core/components/CCLayout.js
@@ -520,9 +520,17 @@ var Layout = cc.Class({
var maxHeightChildAnchorY = 0;
+ var activeChildCount = 0;
+ children.forEach(function(child) {
+ if (!child.activeInHierarchy) {
+ return;
+ }
+ activeChildCount++;
+ });
+
var newChildWidth = this.cellSize.width;
if (this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN) {
- newChildWidth = (baseWidth - (this.paddingLeft + this.paddingRight) - (children.length - 1) * this.spacingX) / children.length;
+ newChildWidth = (baseWidth - (this.paddingLeft + this.paddingRight) - (activeChildCount - 1) * this.spacingX) / activeChildCount;
}
children.forEach(function(child) {
@@ -653,9 +661,17 @@ var Layout = cc.Class({
var containerResizeBoundary = 0;
var maxWidthChildAnchorX = 0;
+ var activeChildCount = 0;
+ children.forEach(function(child) {
+ if (!child.activeInHierarchy) {
+ return;
+ }
+ activeChildCount++;
+ });
+
var newChildHeight = this.cellSize.height;
if (this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN) {
- newChildHeight = (baseHeight - (this.paddingTop + this.paddingBottom) - (children.length - 1) * this.spacingY) / children.length;
+ newChildHeight = (baseHeight - (this.paddingTop + this.paddingBottom) - (activeChildCount - 1) * this.spacingY) / activeChildCount;
}
children.forEach(function(child) {
From 06cc115b767870c184847b6080be4de881bdd8e5 Mon Sep 17 00:00:00 2001
From: knox
Date: Thu, 3 May 2018 09:44:06 +0800
Subject: [PATCH 03/35] improve layout code
---
cocos2d/core/components/CCLayout.js | 134 +++++++++++++++-------------
1 file changed, 71 insertions(+), 63 deletions(-)
diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js
index be07bcfdb0..7d6e2ffa3b 100644
--- a/cocos2d/core/components/CCLayout.js
+++ b/cocos2d/core/components/CCLayout.js
@@ -191,10 +191,10 @@ var Layout = cc.Class({
*/
type: {
type: Type,
- get: function() {
+ get: function () {
return this._N$layoutType;
},
- set: function(value) {
+ set: function (value) {
this._N$layoutType = value;
if (CC_EDITOR && this.type !== Type.NONE && this._resize === ResizeMode.CONTAINER && !cc.engine.isPlaying) {
@@ -222,10 +222,10 @@ var Layout = cc.Class({
type: ResizeMode,
tooltip: CC_DEV && 'i18n:COMPONENT.layout.resize_mode',
animatable: false,
- get: function() {
+ get: function () {
return this._resize;
},
- set: function(value) {
+ set: function (value) {
if (this.type === Type.NONE && value === ResizeMode.CHILDREN) {
return;
}
@@ -251,7 +251,7 @@ var Layout = cc.Class({
default: cc.size(40, 40),
tooltip: CC_DEV && 'i18n:COMPONENT.layout.cell_size',
type: cc.Size,
- notify: function() {
+ notify: function () {
this._doLayoutDirty();
},
},
@@ -267,7 +267,7 @@ var Layout = cc.Class({
default: AxisDirection.HORIZONTAL,
tooltip: CC_DEV && 'i18n:COMPONENT.layout.start_axis',
type: AxisDirection,
- notify: function() {
+ notify: function () {
if (CC_EDITOR && this._resize === ResizeMode.CONTAINER && !cc.engine.isPlaying) {
var reLayouted = _Scene.DetectConflict.checkConflict_Layout(this);
if (reLayouted) {
@@ -341,7 +341,7 @@ var Layout = cc.Class({
*/
spacingX: {
default: 0,
- notify: function() {
+ notify: function () {
this._doLayoutDirty();
},
tooltip: CC_DEV && 'i18n:COMPONENT.layout.space_x'
@@ -354,7 +354,7 @@ var Layout = cc.Class({
*/
spacingY: {
default: 0,
- notify: function() {
+ notify: function () {
this._doLayoutDirty();
},
tooltip: CC_DEV && 'i18n:COMPONENT.layout.space_y'
@@ -370,7 +370,7 @@ var Layout = cc.Class({
verticalDirection: {
default: VerticalDirection.TOP_TO_BOTTOM,
type: VerticalDirection,
- notify: function() {
+ notify: function () {
this._doLayoutDirty();
},
tooltip: CC_DEV && 'i18n:COMPONENT.layout.vertical_direction',
@@ -387,7 +387,7 @@ var Layout = cc.Class({
horizontalDirection: {
default: HorizontalDirection.LEFT_TO_RIGHT,
type: HorizontalDirection,
- notify: function() {
+ notify: function () {
this._doLayoutDirty();
},
tooltip: CC_DEV && 'i18n:COMPONENT.layout.horizontal_direction',
@@ -411,14 +411,14 @@ var Layout = cc.Class({
this._N$padding = 0;
},
- onEnable: function() {
+ onEnable: function () {
this._addEventListeners();
- if(cc.sizeEqualToSize(this.node.getContentSize(), cc.size(0, 0))) {
+ if (cc.sizeEqualToSize(this.node.getContentSize(), cc.size(0, 0))) {
this.node.setContentSize(this._layoutSize);
}
- if(this._N$padding !== 0) {
+ if (this._N$padding !== 0) {
this._migratePaddingData();
}
@@ -429,7 +429,7 @@ var Layout = cc.Class({
this._removeEventListeners();
},
- _doLayoutDirty : function () {
+ _doLayoutDirty: function () {
this._layoutDirty = true;
},
@@ -453,27 +453,29 @@ var Layout = cc.Class({
this._removeChildrenEventListeners();
},
- _addChildrenEventListeners: function() {
+ _addChildrenEventListeners: function () {
var children = this.node.children;
- children.forEach(function (child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
child.on('size-changed', this._doLayoutDirty, this);
child.on('position-changed', this._doLayoutDirty, this);
child.on('anchor-changed', this._doLayoutDirty, this);
child.on('active-in-hierarchy-changed', this._doLayoutDirty, this);
- }.bind(this));
+ }
},
_removeChildrenEventListeners: function () {
var children = this.node.children;
- children.forEach(function (child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
child.off('size-changed', this._doLayoutDirty, this);
child.off('position-changed', this._doLayoutDirty, this);
child.off('anchor-changed', this._doLayoutDirty, this);
child.off('active-in-hierarchy-changed', this._doLayoutDirty, this);
- }.bind(this));
+ }
},
- _childAdded: function(event) {
+ _childAdded: function (event) {
var child = event.detail;
child.on('size-changed', this._doLayoutDirty, this);
child.on('position-changed', this._doLayoutDirty, this);
@@ -483,7 +485,7 @@ var Layout = cc.Class({
this._doLayoutDirty();
},
- _childRemoved: function(event) {
+ _childRemoved: function (event) {
var child = event.detail;
child.off('size-changed', this._doLayoutDirty, this);
child.off('position-changed', this._doLayoutDirty, this);
@@ -493,12 +495,12 @@ var Layout = cc.Class({
this._doLayoutDirty();
},
- _resized: function() {
+ _resized: function () {
this._layoutSize = this.node.getContentSize();
this._doLayoutDirty();
},
- _doLayoutHorizontally: function(baseWidth, rowBreak, fnPositionY, applyChildren) {
+ _doLayoutHorizontally: function (baseWidth, rowBreak, fnPositionY, applyChildren) {
var layoutAnchor = this.node.getAnchorPoint();
var children = this.node.children;
@@ -521,21 +523,23 @@ var Layout = cc.Class({
var maxHeightChildAnchorY = 0;
var activeChildCount = 0;
- children.forEach(function(child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
activeChildCount++;
- });
+ }
var newChildWidth = this.cellSize.width;
if (this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN) {
newChildWidth = (baseWidth - (this.paddingLeft + this.paddingRight) - (activeChildCount - 1) * this.spacingX) / activeChildCount;
}
- children.forEach(function(child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
//for resizing children
if (this._resize === ResizeMode.CHILDREN) {
@@ -582,13 +586,13 @@ var Layout = cc.Class({
secondMaxHeight = child.height;
tempMaxHeight = 0;
}
- nextX = leftBoundaryOfLayout + sign * (paddingX + anchorX * child.width);
+ nextX = leftBoundaryOfLayout + sign * (paddingX + anchorX * child.width);
row++;
}
}
var finalPositionY = fnPositionY(child, rowMaxHeight, row);
- if(baseWidth >= (child.width + this.paddingLeft + this.paddingRight)) {
+ if (baseWidth >= (child.width + this.paddingLeft + this.paddingRight)) {
if (applyChildren) {
child.setPosition(cc.p(nextX, finalPositionY));
}
@@ -601,21 +605,21 @@ var Layout = cc.Class({
if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) {
containerResizeBoundary = containerResizeBoundary || this.node._contentSize.height;
signX = -1;
- tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingBottom);
+ tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingBottom);
if (tempFinalPositionY < containerResizeBoundary) {
containerResizeBoundary = tempFinalPositionY;
}
}
else {
containerResizeBoundary = containerResizeBoundary || -this.node._contentSize.height;
- tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingTop);
+ tempFinalPositionY = finalPositionY + signX * (topMarign * maxHeightChildAnchorY + this.paddingTop);
if (tempFinalPositionY > containerResizeBoundary) {
containerResizeBoundary = tempFinalPositionY;
}
}
nextX += rightBoundaryOfChild;
- }.bind(this));
+ }
return containerResizeBoundary;
},
@@ -624,13 +628,14 @@ var Layout = cc.Class({
var newHeight = 0;
var activeChildCount = 0;
if (this.resizeMode === ResizeMode.CONTAINER) {
- children.forEach(function(child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
activeChildCount++;
newHeight += child.height;
- });
+ }
newHeight += (activeChildCount - 1) * this.spacingY + this.paddingBottom + this.paddingTop;
}
@@ -640,7 +645,7 @@ var Layout = cc.Class({
return newHeight;
},
- _doLayoutVertically: function(baseHeight, columnBreak, fnPositionX, applyChildren) {
+ _doLayoutVertically: function (baseHeight, columnBreak, fnPositionX, applyChildren) {
var layoutAnchor = this.node.getAnchorPoint();
var children = this.node.children;
@@ -662,21 +667,23 @@ var Layout = cc.Class({
var maxWidthChildAnchorX = 0;
var activeChildCount = 0;
- children.forEach(function(child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
activeChildCount++;
- });
+ }
var newChildHeight = this.cellSize.height;
if (this.type !== Type.GRID && this.resizeMode === ResizeMode.CHILDREN) {
newChildHeight = (baseHeight - (this.paddingTop + this.paddingBottom) - (activeChildCount - 1) * this.spacingY) / activeChildCount;
}
- children.forEach(function(child) {
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
//for resizing children
@@ -758,27 +765,27 @@ var Layout = cc.Class({
}
nextY += topBoundaryOfChild;
- }.bind(this));
+ }
return containerResizeBoundary;
},
- _doLayoutBasic: function() {
+ _doLayoutBasic: function () {
var children = this.node.children;
var allChildrenBoundingBox = null;
- children.forEach(function(child){
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
if (!child.activeInHierarchy) {
- return;
+ continue;
}
-
- if(!allChildrenBoundingBox){
+ if (!allChildrenBoundingBox) {
allChildrenBoundingBox = child.getBoundingBoxToWorld();
} else {
allChildrenBoundingBox = cc.rectUnion(allChildrenBoundingBox, child.getBoundingBoxToWorld());
}
- });
+ }
if (allChildrenBoundingBox) {
var leftBottomInParentSpace = this.node.parent.convertToNodeSpaceAR(cc.p(allChildrenBoundingBox.x, allChildrenBoundingBox.y));
@@ -813,7 +820,7 @@ var Layout = cc.Class({
paddingY = this.paddingTop;
}
- var fnPositionY = function(child, topOffset, row) {
+ var fnPositionY = function (child, topOffset, row) {
return bottomBoundaryOfLayout + sign * (topOffset + child.anchorY * child.height + paddingY + row * this.spacingY);
}.bind(this);
@@ -854,7 +861,7 @@ var Layout = cc.Class({
paddingX = this.paddingRight;
}
- var fnPositionX = function(child, leftOffset, column) {
+ var fnPositionX = function (child, leftOffset, column) {
return leftBoundaryOfLayout + sign * (leftOffset + child.anchorX * child.width + paddingX + column * this.spacingX);
}.bind(this);
@@ -881,7 +888,7 @@ var Layout = cc.Class({
}
},
- _doLayoutGrid: function() {
+ _doLayoutGrid: function () {
var layoutAnchor = this.node.getAnchorPoint();
var layoutSize = this.node.getContentSize();
@@ -889,7 +896,7 @@ var Layout = cc.Class({
this._doLayoutGridAxisHorizontal(layoutAnchor, layoutSize);
}
- else if(this.startAxis === AxisDirection.VERTICAL) {
+ else if (this.startAxis === AxisDirection.VERTICAL) {
this._doLayoutGridAxisVertical(layoutAnchor, layoutSize);
}
@@ -899,13 +906,14 @@ var Layout = cc.Class({
var newWidth = 0;
var activeChildCount = 0;
if (this.resizeMode === ResizeMode.CONTAINER) {
- children.forEach(function(child) {
- if(!child.activeInHierarchy) {
- return;
+ for (var i = 0; i < children.length; ++i) {
+ var child = children[i];
+ if (!child.activeInHierarchy) {
+ continue;
}
activeChildCount++;
newWidth += child.width;
- });
+ }
newWidth += (activeChildCount - 1) * this.spacingX + this.paddingLeft + this.paddingRight;
}
else {
@@ -914,23 +922,23 @@ var Layout = cc.Class({
return newWidth;
},
- _doLayout: function() {
+ _doLayout: function () {
if (this.type === Type.HORIZONTAL) {
var newWidth = this._getHorizontalBaseWidth(this.node.children);
- var fnPositionY = function(child) {
+ var fnPositionY = function (child) {
return child.y;
};
- this._doLayoutHorizontally( newWidth, false, fnPositionY, true);
+ this._doLayoutHorizontally(newWidth, false, fnPositionY, true);
this.node.width = newWidth;
}
else if (this.type === Type.VERTICAL) {
var newHeight = this._getVerticalBaseHeight(this.node.children);
- var fnPositionX = function(child) {
+ var fnPositionX = function (child) {
return child.x;
};
@@ -943,7 +951,7 @@ var Layout = cc.Class({
this._doLayoutBasic();
}
}
- else if(this.type === Type.GRID) {
+ else if (this.type === Type.GRID) {
this._doLayoutGrid();
}
},
@@ -961,7 +969,7 @@ var Layout = cc.Class({
* layout.updateLayout();
* cc.log(childNode.x); // changed
*/
- updateLayout: function() {
+ updateLayout: function () {
if (this._layoutDirty && this.node.children.length > 0) {
this._doLayout();
this._layoutDirty = false;
From 8e45081cabe6effa45a3ab908d42638e06f3eb76 Mon Sep 17 00:00:00 2001
From: knox
Date: Thu, 3 May 2018 10:03:14 +0800
Subject: [PATCH 04/35] add osMainVersion and supportArrayBuffer to qqplay
---
cocos2d/core/platform/CCSys.js | 5 ++++-
cocos2d/core/renderer/RendererWebGL.js | 10 ++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index 86661c14cc..932094eefd 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -614,10 +614,13 @@ else if (CC_QQPLAY) {
var version = /[\d\.]+/.exec(env.version);
sys.osVersion = version[0];
- sys.osMainVersion = 0;
+ sys.osMainVersion = parseInt(osVersion.split('.')[0]);
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
sys.browserVersion = 0;
+ // todo Can be removed after qqplay with support
+ sys.supportArrayBuffer = sys.os === sys.OS_IOS && sys.osMainVersion < 10;
+
var w = env.screenWidth;
var h = env.screenHeight;
var ratio = env.pixelRatio || 1;
diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js
index e1f9baec79..a465613973 100644
--- a/cocos2d/core/renderer/RendererWebGL.js
+++ b/cocos2d/core/renderer/RendererWebGL.js
@@ -143,12 +143,6 @@ cc.rendererWebGL = {
initQuadBuffer(cc.macro.BATCH_VERTEX_COUNT);
if (cc.sys.os === cc.sys.OS_IOS) {
_IS_IOS = true;
-
- // todo Can be removed after qqplay with support
- let version = cc.sys.osVersion.split('.');
- if (cc.sys.platform === cc.sys.QQ_PLAY && version[0] < 10) {
- cc.sys.isOldIOS = true;
- }
}
},
@@ -444,7 +438,7 @@ cc.rendererWebGL = {
gl.bindBuffer(gl.ARRAY_BUFFER, _vertexBuffer);
// upload the vertex data to the gl buffer
if (uploadAll) {
- if (cc.sys.isOldIOS) {
+ if (CC_QQPLAY && cc.sys.supportArrayBuffer) {
gl.bufferDataOldIOS(gl.ARRAY_BUFFER, _vertexDataF32, _vertexDataUI32, gl.DYNAMIC_DRAW);
}
else
@@ -452,7 +446,7 @@ cc.rendererWebGL = {
}
else {
var view = _vertexDataF32.subarray(0, _batchingSize * _sizePerVertex);
- if (cc.sys.isOldIOS) {
+ if (CC_QQPLAY && cc.sys.supportArrayBuffer) {
var viewUI32 = _vertexDataUI32.subarray(0, _batchingSize * _sizePerVertex);
gl.bufferDataOldIOS(gl.ARRAY_BUFFER, view, viewUI32, gl.DYNAMIC_DRAW);
}
From e45c5cd1a92b7f86ee89d542e89494fd6ece6c56 Mon Sep 17 00:00:00 2001
From: knox
Date: Fri, 4 May 2018 09:57:43 +0800
Subject: [PATCH 05/35] improve code
---
cocos2d/core/components/CCLayout.js | 37 +++++++++++++----------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js
index 7d6e2ffa3b..37440838e0 100644
--- a/cocos2d/core/components/CCLayout.js
+++ b/cocos2d/core/components/CCLayout.js
@@ -525,10 +525,9 @@ var Layout = cc.Class({
var activeChildCount = 0;
for (var i = 0; i < children.length; ++i) {
var child = children[i];
- if (!child.activeInHierarchy) {
- continue;
+ if (child.activeInHierarchy) {
+ activeChildCount++;
}
- activeChildCount++;
}
var newChildWidth = this.cellSize.width;
@@ -630,11 +629,10 @@ var Layout = cc.Class({
if (this.resizeMode === ResizeMode.CONTAINER) {
for (var i = 0; i < children.length; ++i) {
var child = children[i];
- if (!child.activeInHierarchy) {
- continue;
+ if (child.activeInHierarchy) {
+ activeChildCount++;
+ newHeight += child.height;
}
- activeChildCount++;
- newHeight += child.height;
}
newHeight += (activeChildCount - 1) * this.spacingY + this.paddingBottom + this.paddingTop;
@@ -669,10 +667,9 @@ var Layout = cc.Class({
var activeChildCount = 0;
for (var i = 0; i < children.length; ++i) {
var child = children[i];
- if (!child.activeInHierarchy) {
- continue;
+ if (child.activeInHierarchy) {
+ activeChildCount++;
}
- activeChildCount++;
}
var newChildHeight = this.cellSize.height;
@@ -777,13 +774,12 @@ var Layout = cc.Class({
for (var i = 0; i < children.length; ++i) {
var child = children[i];
- if (!child.activeInHierarchy) {
- continue;
- }
- if (!allChildrenBoundingBox) {
- allChildrenBoundingBox = child.getBoundingBoxToWorld();
- } else {
- allChildrenBoundingBox = cc.rectUnion(allChildrenBoundingBox, child.getBoundingBoxToWorld());
+ if (child.activeInHierarchy) {
+ if (!allChildrenBoundingBox) {
+ allChildrenBoundingBox = child.getBoundingBoxToWorld();
+ } else {
+ allChildrenBoundingBox = cc.rectUnion(allChildrenBoundingBox, child.getBoundingBoxToWorld());
+ }
}
}
@@ -908,11 +904,10 @@ var Layout = cc.Class({
if (this.resizeMode === ResizeMode.CONTAINER) {
for (var i = 0; i < children.length; ++i) {
var child = children[i];
- if (!child.activeInHierarchy) {
- continue;
+ if (child.activeInHierarchy) {
+ activeChildCount++;
+ newWidth += child.width;
}
- activeChildCount++;
- newWidth += child.width;
}
newWidth += (activeChildCount - 1) * this.spacingX + this.paddingLeft + this.paddingRight;
}
From d9a6cd746c60e6c3f41a4fe4077aabd03e8c3a00 Mon Sep 17 00:00:00 2001
From: knox
Date: Fri, 4 May 2018 10:07:38 +0800
Subject: [PATCH 06/35] improve code
---
cocos2d/core/platform/CCSys.js | 4 ++--
cocos2d/core/renderer/RendererWebGL.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index 932094eefd..ffed7d2540 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -618,8 +618,8 @@ else if (CC_QQPLAY) {
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
sys.browserVersion = 0;
- // todo Can be removed after qqplay with support
- sys.supportArrayBuffer = sys.os === sys.OS_IOS && sys.osMainVersion < 10;
+ // todo Can be removed after qqplay with support (ArrayBuffer)
+ sys.noABSupport = sys.os === sys.OS_IOS && sys.osMainVersion < 10;
var w = env.screenWidth;
var h = env.screenHeight;
diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js
index a465613973..b5e351a295 100644
--- a/cocos2d/core/renderer/RendererWebGL.js
+++ b/cocos2d/core/renderer/RendererWebGL.js
@@ -438,7 +438,7 @@ cc.rendererWebGL = {
gl.bindBuffer(gl.ARRAY_BUFFER, _vertexBuffer);
// upload the vertex data to the gl buffer
if (uploadAll) {
- if (CC_QQPLAY && cc.sys.supportArrayBuffer) {
+ if (CC_QQPLAY && cc.sys.noABSupport) {
gl.bufferDataOldIOS(gl.ARRAY_BUFFER, _vertexDataF32, _vertexDataUI32, gl.DYNAMIC_DRAW);
}
else
@@ -446,7 +446,7 @@ cc.rendererWebGL = {
}
else {
var view = _vertexDataF32.subarray(0, _batchingSize * _sizePerVertex);
- if (CC_QQPLAY && cc.sys.supportArrayBuffer) {
+ if (CC_QQPLAY && cc.sys.noABSupport) {
var viewUI32 = _vertexDataUI32.subarray(0, _batchingSize * _sizePerVertex);
gl.bufferDataOldIOS(gl.ARRAY_BUFFER, view, viewUI32, gl.DYNAMIC_DRAW);
}
From 32205ee27bbe3768c3b3138b3432f64a65c95da7 Mon Sep 17 00:00:00 2001
From: Jare Guo
Date: Sat, 5 May 2018 00:43:31 +0800
Subject: [PATCH 07/35] define apisrc.json in this repo
---
cocos2d/actions/CCActionManager.js | 2 +-
cocos2d/animation/animation-clip.js | 4 +-
cocos2d/core/CCNode.js | 2 +-
cocos2d/core/CCScheduler.js | 10 +--
cocos2d/core/event-manager/CCEventListener.js | 2 +-
cocos2d/core/event-manager/CCEventManager.js | 4 +-
cocos2d/core/event/event-target.js | 2 +-
cocos2d/core/platform/CCEnum.js | 2 +-
cocos2d/core/platform/CCMacro.js | 4 +-
cocos2d/core/platform/url.js | 4 +-
cocos2d/core/textures/CCTextureCache.js | 14 ++---
cocos2d/core/utils/CCPath.js | 12 ++--
cocos2d/core/value-types/CCColor.js | 6 +-
cocos2d/core/value-types/CCSize.js | 2 +-
docs/apisrc.json | 62 +++++++++++++++++++
extensions/ccpool/CCPool.js | 2 +-
16 files changed, 98 insertions(+), 36 deletions(-)
create mode 100644 docs/apisrc.json
diff --git a/cocos2d/actions/CCActionManager.js b/cocos2d/actions/CCActionManager.js
index 65bcbfa56a..1ca5cce5fe 100644
--- a/cocos2d/actions/CCActionManager.js
+++ b/cocos2d/actions/CCActionManager.js
@@ -56,7 +56,7 @@ var HashElement = function () {
* - 当你想要运行一个动作,但目标不是 CCNode 类型时。
* - 当你想要暂停/恢复动作时。
* @class ActionManager
- * @example {@link utils/api/engine/docs/cocos2d/core/CCActionManager/ActionManager.js}
+ * @example {@link cocos2d/core/CCActionManager/ActionManager.js}
*/
cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
diff --git a/cocos2d/animation/animation-clip.js b/cocos2d/animation/animation-clip.js
index 5eecfd7f08..763017e865 100644
--- a/cocos2d/animation/animation-clip.js
+++ b/cocos2d/animation/animation-clip.js
@@ -85,7 +85,7 @@ var AnimationClip = cc.Class({
* !#zh 曲线数据。
* @property curveData
* @type {Object}
- * @example {@link utils/api/engine/docs/cocos2d/core/animation-clip/curve-data.js}
+ * @example {@link cocos2d/core/animation-clip/curve-data.js}
*/
curveData: {
default: {},
@@ -97,7 +97,7 @@ var AnimationClip = cc.Class({
* !#zh 事件数据。
* @property events
* @type {Object[]}
- * @example {@link utils/api/engine/docs/cocos2d/core/animation-clip/event-data.js}
+ * @example {@link cocos2d/core/animation-clip/event-data.js}
* @typescript events: {frame: number, func: string, params: string[]}[]
*/
events: {
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index a5c94c0bbf..77a8f7b127 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -1621,7 +1621,7 @@ var Node = cc.Class({
* @method setPosition
* @param {Vec2|Number} newPosOrX - X coordinate for position or the position (x, y) of the node in coordinates
* @param {Number} [y] - Y coordinate for position
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/base-node/setPosition.js}
+ * @example {@link cocos2d/core/utils/base-node/setPosition.js}
*/
setPosition (newPosOrX, y) {
var x;
diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js
index e2eb4d166d..d738912cd1 100644
--- a/cocos2d/core/CCScheduler.js
+++ b/cocos2d/core/CCScheduler.js
@@ -505,7 +505,7 @@ cc.Scheduler = cc._Class.extend({
* @param {Number} [repeat=cc.macro.REPEAT_FOREVER]
* @param {Number} [delay=0]
* @param {Boolean} paused
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/scheduleCallbackForTarget.js}
+ * @example {@link cocos2d/core/CCScheduler/scheduleCallbackForTarget.js}
* @typescript
* scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void
* scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void
@@ -525,7 +525,7 @@ cc.Scheduler = cc._Class.extend({
* @param {Number} [repeat=cc.macro.REPEAT_FOREVER]
* @param {Number} [delay=0]
* @param {Boolean} paused
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/schedule.js}
+ * @example {@link cocos2d/core/CCScheduler/schedule.js}
* @typescript
* schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void
* schedule(callback: Function, target: any, interval: number, paused?: boolean): void
@@ -1051,7 +1051,7 @@ cc.Scheduler = cc._Class.extend({
* @param {Object} target
* @param {Number} priority
* @param {Boolean} paused
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/scheduleUpdateForTarget.js}
+ * @example {@link cocos2d/core/CCScheduler/scheduleUpdateForTarget.js}
*/
scheduleUpdateForTarget: function(target, priority, paused){
//cc.log("scheduleUpdateForTarget is deprecated. Please use scheduleUpdate.");
@@ -1069,7 +1069,7 @@ cc.Scheduler = cc._Class.extend({
* @deprecated since v3.4 please use .unschedule
* @param {Object} target
* @param {Function} callback - callback[Function] or key[String]
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/unscheduleCallbackForTarget.js}
+ * @example {@link cocos2d/core/CCScheduler/unscheduleCallbackForTarget.js}
*/
unscheduleCallbackForTarget: function (target, callback) {
//cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule.");
@@ -1082,7 +1082,7 @@ cc.Scheduler = cc._Class.extend({
* @method unscheduleUpdateForTarget
* @param {Object} target
* @deprecated since v3.4 please use .unschedule
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/unscheduleUpdateForTarget.js}
+ * @example {@link cocos2d/core/CCScheduler/unscheduleUpdateForTarget.js}
*/
unscheduleUpdateForTarget: function (target) {
//cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule.");
diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js
index d3bac346ff..f952cc96dc 100644
--- a/cocos2d/core/event-manager/CCEventListener.js
+++ b/cocos2d/core/event-manager/CCEventListener.js
@@ -459,7 +459,7 @@ cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
* @param {Object} argObj a json object
* @returns {EventListener}
* @static
- * @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventListener/create.js}
+ * @example {@link cocos2d/core/event-manager/CCEventListener/create.js}
*/
cc.EventListener.create = function(argObj){
diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js
index eb6d9b9565..ae52fb4cfd 100644
--- a/cocos2d/core/event-manager/CCEventManager.js
+++ b/cocos2d/core/event-manager/CCEventManager.js
@@ -101,7 +101,7 @@ var __getListenerID = function (event) {
*
* @class eventManager
* @static
- * @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventManager/addListener.js}
+ * @example {@link cocos2d/core/event-manager/CCEventManager/addListener.js}
* @deprecated
*/
var eventManager = {
@@ -806,7 +806,7 @@ var eventManager = {
* !#zh 移除一个已添加的监听器。
* @method removeListener
* @param {EventListener} listener - an event listener or a registered node target
- * @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventManager/removeListener.js}
+ * @example {@link cocos2d/core/event-manager/CCEventManager/removeListener.js}
*/
removeListener: function (listener) {
if (listener == null)
diff --git a/cocos2d/core/event/event-target.js b/cocos2d/core/event/event-target.js
index 3e60fa23de..2d17ec3fa1 100644
--- a/cocos2d/core/event/event-target.js
+++ b/cocos2d/core/event/event-target.js
@@ -469,7 +469,7 @@ proto._isTargetActive = function (type) {
* @method _getCapturingTargets
* @param {String} type - the event type
* @param {Array} array - the array to receive targets
- * @example {@link utils/api/engine/docs/cocos2d/core/event/_getCapturingTargets.js}
+ * @example {@link cocos2d/core/event/_getCapturingTargets.js}
*/
proto._getCapturingTargets = function (type, array) {
diff --git a/cocos2d/core/platform/CCEnum.js b/cocos2d/core/platform/CCEnum.js
index c04c5b207c..74cc9ff944 100644
--- a/cocos2d/core/platform/CCEnum.js
+++ b/cocos2d/core/platform/CCEnum.js
@@ -41,7 +41,7 @@ var JS = require('./js');
* @method Enum
* @param {object} obj - a JavaScript literal object containing enum names and values, or a TypeScript enum type
* @return {object} the defined enum type
- * @example {@link utils/api/engine/docs/cocos2d/core/platform/CCEnum/Enum.js}
+ * @example {@link cocos2d/core/platform/CCEnum/Enum.js}
* @typescript Enum(obj: T): T
*/
function Enum (obj) {
diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js
index b239d555ef..3c0884f136 100644
--- a/cocos2d/core/platform/CCMacro.js
+++ b/cocos2d/core/platform/CCMacro.js
@@ -31,7 +31,7 @@ require('./_CCClass');
* !#en Key map for keyboard event
* !#zh 键盘事件的按键值
* @enum KEY
- * @example {@link utils/api/engine/docs/cocos2d/core/platform/CCCommon/KEY.js}
+ * @example {@link cocos2d/core/platform/CCCommon/KEY.js}
*/
cc.KEY = {
/**
@@ -2003,7 +2003,7 @@ cc.defineGetterSetter(cc.macro, "BLEND_SRC", function (){
* @param {Number} a number A
* @param {Number} b number B
* @param {Number} r ratio between 0 and 1
- * @example {@link utils/api/engine/docs/cocos2d/core/platform/CCMacro/lerp.js}
+ * @example {@link cocos2d/core/platform/CCMacro/lerp.js}
*/
cc.lerp = function (a, b, r) {
return a + (b - a) * r;
diff --git a/cocos2d/core/platform/url.js b/cocos2d/core/platform/url.js
index c835eac7b3..986833a82a 100644
--- a/cocos2d/core/platform/url.js
+++ b/cocos2d/core/platform/url.js
@@ -69,7 +69,7 @@ cc.url = {
* @method raw
* @param {String} url
* @return {String}
- * @example {@link utils/api/engine/docs/cocos2d/core/platform/url/raw.js}
+ * @example {@link cocos2d/core/platform/url/raw.js}
*/
raw: function (url) {
if (CC_EDITOR && !this._rawAssets) {
@@ -103,7 +103,7 @@ cc.url = {
* @method builtinRaw
* @param {String} url
* @return {String}
- * @example {@link utils/api/engine/docs/cocos2d/core/platform/url/builtinRaw.js}
+ * @example {@link cocos2d/core/platform/url/builtinRaw.js}
*/
builtinRaw: CC_EDITOR && function (url) {
if ( !this._builtinRawAssets ) {
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js
index 7e04b02a03..7c10895d44 100644
--- a/cocos2d/core/textures/CCTextureCache.js
+++ b/cocos2d/core/textures/CCTextureCache.js
@@ -52,7 +52,7 @@ var textureCache = /** @lends cc.textureCache# */{
* @method getTextureForKey
* @param {String} textureKeyName
* @return {Texture2D|Null}
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/getTextureForKey.js}
+ * @example {@link cocos2d/core/textures/getTextureForKey.js}
*/
getTextureForKey: function(textureKeyName){
return this._textures[textureKeyName];
@@ -62,7 +62,7 @@ var textureCache = /** @lends cc.textureCache# */{
* @method getKeyByTexture
* @param {HTMLImageElement} texture
* @return {String|Null}
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/getKeyByTexture.js}
+ * @example {@link cocos2d/core/textures/getKeyByTexture.js}
*/
getKeyByTexture: function (texture) {
for (var key in this._textures) {
@@ -81,7 +81,7 @@ var textureCache = /** @lends cc.textureCache# */{
* @method getTextureColors
* @param {HTMLImageElement} texture
* @return {Array}
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/getTextureColors.js}
+ * @example {@link cocos2d/core/textures/getTextureColors.js}
*/
getTextureColors: function (texture) {
var image = texture._image;
@@ -120,7 +120,7 @@ var textureCache = /** @lends cc.textureCache# */{
* In the medium term: it will allocate more resources
* In the long term: it will be the same
* @method removeAllTextures
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/removeAllTextures.js}
+ * @example {@link cocos2d/core/textures/removeAllTextures.js}
*/
removeAllTextures: function () {
var locTextures = this._textures;
@@ -135,7 +135,7 @@ var textureCache = /** @lends cc.textureCache# */{
* Deletes a texture from the cache given a texture.
* @method removeTexture
* @param {HTMLImageElement} texture
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/removeTexture.js}
+ * @example {@link cocos2d/core/textures/removeTexture.js}
*/
removeTexture: function (texture) {
if (!texture)
@@ -154,7 +154,7 @@ var textureCache = /** @lends cc.textureCache# */{
* Deletes a texture from the cache given a its key name.
* @method removeTextureForKey
* @param {String} textureKeyName
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/removeTextureForKey.js}
+ * @example {@link cocos2d/core/textures/removeTextureForKey.js}
*/
removeTextureForKey: function (textureKeyName) {
if (CC_DEBUG && textureKeyName instanceof cc.Texture2D) {
@@ -183,7 +183,7 @@ var textureCache = /** @lends cc.textureCache# */{
* @param {Function} cb
* @param {Object} target
* @return {Texture2D}
- * @example {@link utils/api/engine/docs/cocos2d/core/textures/addImage.js}
+ * @example {@link cocos2d/core/textures/addImage.js}
*/
addImage (url, cb, target) {
if (CC_DEBUG && url instanceof cc.Texture2D) {
diff --git a/cocos2d/core/utils/CCPath.js b/cocos2d/core/utils/CCPath.js
index 0ca52d6c2d..d3749c52fe 100644
--- a/cocos2d/core/utils/CCPath.js
+++ b/cocos2d/core/utils/CCPath.js
@@ -41,7 +41,7 @@ cc.path = /** @lends cc.path# */{
* !#en Join strings to be a path.
* !#zh 拼接字符串为 Path
* @method join
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/join.js}
+ * @example {@link cocos2d/core/utils/CCPath/join.js}
* @returns {String}
*/
join: function () {
@@ -57,7 +57,7 @@ cc.path = /** @lends cc.path# */{
* !#en Get the ext name of a path including '.', like '.png'.
* !#zh 返回 Path 的扩展名,包括 '.',例如 '.png'。
* @method extname
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/extname.js}
+ * @example {@link cocos2d/core/utils/CCPath/extname.js}
* @param {String} pathStr
* @returns {*}
*/
@@ -87,7 +87,7 @@ cc.path = /** @lends cc.path# */{
* !#en Get the file name of a file path.
* !#zh 获取文件路径的文件名。
* @method basename
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/basename.js}
+ * @example {@link cocos2d/core/utils/CCPath/basename.js}
* @param {String} pathStr
* @param {String} [extname]
* @returns {*}
@@ -108,7 +108,7 @@ cc.path = /** @lends cc.path# */{
* !#en Get dirname of a file path.
* !#zh 获取文件路径的目录名。
* @method dirname
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/dirname.js}
+ * @example {@link cocos2d/core/utils/CCPath/dirname.js}
* @param {String} pathStr
* @returns {*}
*/
@@ -121,7 +121,7 @@ cc.path = /** @lends cc.path# */{
* !#en Change extname of a file path.
* !#zh 更改文件路径的扩展名。
* @method changeExtname
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/changeExtname.js}
+ * @example {@link cocos2d/core/utils/CCPath/changeExtname.js}
* @param {String} pathStr
* @param {String} [extname]
* @returns {String}
@@ -141,7 +141,7 @@ cc.path = /** @lends cc.path# */{
/**
* !#en Change file name of a file path.
* !#zh 更改文件路径的文件名。
- * @example {@link utils/api/engine/docs/cocos2d/core/utils/CCPath/changeBasename.js}
+ * @example {@link cocos2d/core/utils/CCPath/changeBasename.js}
* @param {String} pathStr
* @param {String} basename
* @param {Boolean} [isSameExt]
diff --git a/cocos2d/core/value-types/CCColor.js b/cocos2d/core/value-types/CCColor.js
index 25d645aee4..f3069811c5 100644
--- a/cocos2d/core/value-types/CCColor.js
+++ b/cocos2d/core/value-types/CCColor.js
@@ -211,7 +211,7 @@ var Color = (function () {
* @param {number} ratio - the interpolation coefficient.
* @param {Color} [out] - optional, the receiving vector.
* @return {Color}
- * @example {@link utils/api/engine/docs/cocos2d/core/value-types/CCColor/lerp.js}
+ * @example {@link cocos2d/core/value-types/CCColor/lerp.js}
*/
proto.lerp = function (to, ratio, out) {
out = out || new Color();
@@ -347,7 +347,7 @@ var Color = (function () {
* @method toCSS
* @param {String} opt - "rgba", "rgb", "#rgb" or "#rrggbb".
* @return {String}
- * @example {@link utils/api/engine/docs/cocos2d/core/value-types/CCColor/toCSS.js}
+ * @example {@link cocos2d/core/value-types/CCColor/toCSS.js}
*/
proto.toCSS = function ( opt ) {
if ( opt === 'rgba' ) {
@@ -630,7 +630,7 @@ cc.Color = Color;
* @param {Number} [b=0]
* @param {Number} [a=255]
* @return {Color}
- * @example {@link utils/api/engine/docs/cocos2d/core/value-types/CCColor/color.js}
+ * @example {@link cocos2d/core/value-types/CCColor/color.js}
*/
cc.color = function color (r, g, b, a) {
if (typeof r === 'string') {
diff --git a/cocos2d/core/value-types/CCSize.js b/cocos2d/core/value-types/CCSize.js
index 4bd25423f6..0843be4e70 100644
--- a/cocos2d/core/value-types/CCSize.js
+++ b/cocos2d/core/value-types/CCSize.js
@@ -163,7 +163,7 @@ proto.toString = function () {
* @param {Number|Size} w - width or a size object
* @param {Number} [h] - height
* @return {Size}
- * @example {@link utils/api/engine/docs/cocos2d/core/value-types/CCSize/size.js}
+ * @example {@link cocos2d/core/value-types/CCSize/size.js}
*/
cc.size = function (w, h) {
return new Size(w, h);
diff --git a/docs/apisrc.json b/docs/apisrc.json
new file mode 100644
index 0000000000..f8ae96561f
--- /dev/null
+++ b/docs/apisrc.json
@@ -0,0 +1,62 @@
+[
+ "./index.js",
+ "./predefine.js",
+ "./CCDebugger.js",
+ "./CCBoot.js",
+ "./extensions/ccpool/*.js",
+ "./extensions/spine/*.js",
+ "./cocos2d/core/load-pipeline/*.js",
+ "!./cocos2d/core/load-pipeline/asset-table.js",
+ "./cocos2d/core/CCNode.js",
+ "./cocos2d/core/CCActionManager.js",
+ "./cocos2d/core/CCScene.js",
+ "./cocos2d/core/CCGame.js",
+ "./cocos2d/core/CCDirector.js",
+ "./cocos2d/core/CCScheduler.js",
+ "./cocos2d/core/sprites/CCSpriteFrame.js",
+ "./cocos2d/core/utils/find.js",
+ "./cocos2d/core/utils/base-node.js",
+ "./cocos2d/animation/bezier.js",
+ "./cocos2d/animation/types.js",
+ "./cocos2d/animation/animation-clip.js",
+ "./cocos2d/animation/animators.js",
+ "./cocos2d/animation/animation-manager.js",
+ "./cocos2d/animation/animation-state.js",
+ "./cocos2d/animation/animation-animator.js",
+ "./cocos2d/animation/playable.js",
+ "./cocos2d/core/platform/**.*",
+ "!./cocos2d/core/platform/_CCClass.js",
+ "!./cocos2d/core/platform/CCAssetLibrary.js",
+ "!./cocos2d/core/platform/CCSAXParser.js",
+ "!./cocos2d/core/platform/load-manager.js",
+ "!./cocos2d/core/platform/prefab-helper.js",
+ "!./cocos2d/core/platform/preprocess-attrs.js",
+ "!./cocos2d/core/platform/requiring-frame.js",
+ "!./cocos2d/core/platform/utils.js",
+ "!./cocos2d/core/platform/id-generater.js",
+ "./cocos2d/core/value-types/**/*",
+ "./cocos2d/core/event/**/*",
+ "./cocos2d/core/assets/**/*",
+ "./cocos2d/core/components/**/*",
+ "./cocos2d/core/support/**/*",
+ "!./cocos2d/core/support/TransformUtils.js",
+ "./cocos2d/core/event-manager/**/*",
+ "./cocos2d/core/textures/**/*",
+ "./cocos2d/actions/**/*",
+ "!./cocos2d/actions/CCActionCamera.js",
+ "!./cocos2d/actions/CCActionTween.js",
+ "./cocos2d/audio/*",
+ "./cocos2d/particle/CCParticleSystem.js",
+ "./cocos2d/tilemap/CCTiledMap.js",
+ "./cocos2d/tilemap/CCTiledLayer.js",
+ "./cocos2d/tilemap/CCSGTMXObject.js",
+ "./cocos2d/tilemap/CCTiledObjectGroup.js",
+ "./cocos2d/tilemap/CCTiledMapAsset.js",
+ "./cocos2d/motion-streak/CCMotionStreak.js",
+ "./cocos2d/core/collider/**/*",
+ "./cocos2d/core/graphics/**/*",
+ "./extensions/anysdk/*",
+ "./extensions/dragonbones/*.js",
+ "./cocos2d/core/physics/**/*",
+ "./cocos2d/core/camera/CCCamera.js"
+]
\ No newline at end of file
diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js
index f343895392..8c14a13daa 100644
--- a/extensions/ccpool/CCPool.js
+++ b/extensions/ccpool/CCPool.js
@@ -60,7 +60,7 @@ cc.pool = /** @lends cc.pool# */{
* !#zh 加入对象到对象池中。
* @method putInPool
* @param {Object} obj - The need put in pool object.
- * @example {@link utils/api/engine/docs/extensions/ccpool/putInPool.js}
+ * @example {@link extensions/ccpool/putInPool.js}
*/
putInPool: function (obj) {
var cid = cc.js._getClassId(obj.constructor);
From 4d3a92111615d8748b07aed39bbaa9f146e16826 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E5=AE=B6=E8=BE=89?=
<35832931+ColinCollins@users.noreply.github.com>
Date: Mon, 7 May 2018 11:46:38 +0800
Subject: [PATCH 08/35] add a new judgement about mobile platform type in
wecaht devtools (#2623)
---
cocos2d/core/platform/CCSys.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index ffed7d2540..be76e17638 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -562,6 +562,15 @@ else if (CC_WECHATGAME) {
else if (env.platform === "ios") {
sys.os = sys.OS_IOS;
}
+ else if (env.platform === 'devtools') {
+ var system = env.system.toLowerCase();
+ if (system.indexOf('android') > -1) {
+ sys.os = sys.OS_ANDROID;
+ }
+ else if (system.indexOf('ios') > -1) {
+ sys.os = sys.OS_IOS;
+ }
+ }
var version = /[\d\.]+/.exec(env.system);
sys.osVersion = version[0];
From f4568fada0860d194aa389bfa732d49786656356 Mon Sep 17 00:00:00 2001
From: Knox
Date: Mon, 7 May 2018 14:24:41 +0800
Subject: [PATCH 09/35] optimization audio label texture2d , fix sprite bug
(#2631)
* optimization audio label texture2d , fix sprite bug
* refine code
---
CCBoot.js | 2 +-
cocos2d/audio/CCAudio.js | 19 ++++++++++++-------
cocos2d/core/label/CCSGLabel.js | 3 ++-
cocos2d/core/platform/CCSys.js | 2 +-
cocos2d/core/sprites/CCScale9Sprite.js | 5 +----
cocos2d/core/textures/CCTexture2D.js | 1 +
6 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/CCBoot.js b/CCBoot.js
index 98fc89518c..ab629dedca 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -32,7 +32,7 @@ cc._LogInfos = cc._LogInfos || {};
* @property {String} ENGINE_VERSION
*/
var engineVersion;
-engineVersion = '1.6.0';
+engineVersion = '1.9.0';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index 86635d7e19..70e20bc8c6 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -138,10 +138,15 @@ Audio.State = {
};
proto.mount = function (elem) {
- if (sys.platform === sys.WECHAT_GAME || elem instanceof HTMLElement) {
- this._element = document.createElement('audio');
- this._element.src = elem.src;
- this._audioType = Audio.Type.DOM;
+ if (elem instanceof HTMLElement) {
+ if (CC_QQPLAY || CC_WECHATGAME) {
+ this._element = elem;
+ }
+ else {
+ this._element = document.createElement('audio');
+ this._element.src = elem.src;
+ this._audioType = Audio.Type.DOM;
+ }
} else {
this._element = new WebAudioElement(elem, this);
this._audioType = Audio.Type.WEBAUDIO;
@@ -157,7 +162,7 @@ Audio.State = {
this.emit('play');
this._state = Audio.State.PLAYING;
- if (sys.platform !== sys.WECHAT_GAME &&
+ if (!(CC_QQPLAY || CC_WECHATGAME) &&
this._audioType === Audio.Type.DOM &&
this._element.paused) {
touchPlayList.push({ instance: this, offset: 0, audio: this._element });
@@ -242,7 +247,7 @@ Audio.State = {
proto.setCurrentTime = function (num) {
if (!this._element) return;
this._unbindEnded();
- if (sys.platform !== sys.WECHAT_GAME) {
+ if (!(CC_QQPLAY || CC_WECHATGAME)) {
this._bindEnded(function () {
this._bindEnded();
}.bind(this));
@@ -374,7 +379,7 @@ var WebAudioElement = function (buffer, audio) {
var self = this;
clearTimeout(this._currextTimer);
this._currextTimer = setTimeout(function () {
- if (sys.platform !== sys.WECHAT_GAME && self._context.currentTime === 0) {
+ if (!(CC_QQPLAY || CC_WECHATGAME) && self._context.currentTime === 0) {
touchPlayList.push({
instance: self._audio,
offset: offset,
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index 019624a829..564c4a2c7b 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -1272,12 +1272,13 @@ _ccsg.Label.pool = new JS.Pool(function (label) {
label._resetBMFont();
label._renderCmd._labelCanvas.width = 1;
label._renderCmd._labelCanvas.height = 1;
+ label._renderCmd._texture.releaseTexture();
if (CC_DEV) {
cc.assert(!label._parent, 'Recycling label\'s parent should be null!');
}
label._updateLabel();
return true;
-}, 20);
+}, 120);
_ccsg.Label.pool.get = function (string, fontAsset) {
var label = this._get();
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index be76e17638..f26fab9100 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -623,7 +623,7 @@ else if (CC_QQPLAY) {
var version = /[\d\.]+/.exec(env.version);
sys.osVersion = version[0];
- sys.osMainVersion = parseInt(osVersion.split('.')[0]);
+ sys.osMainVersion = parseInt(sys.osVersion.split('.')[0]);
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
sys.browserVersion = 0;
diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js
index eb8f76b452..ad71c77959 100644
--- a/cocos2d/core/sprites/CCScale9Sprite.js
+++ b/cocos2d/core/sprites/CCScale9Sprite.js
@@ -1194,10 +1194,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
this._renderCmd._needDraw = false;
var self = this;
var onResourceDataLoaded = function () {
- if (!self.isValid) {
- return;
- }
- if (cc.sizeEqualToSize(self._contentSize, cc.size(0, 0))) {
+ if (self._spriteFrame && cc.sizeEqualToSize(self._contentSize, cc.size(0, 0))) {
self.setContentSize(self._spriteFrame._rect);
}
self._renderCmd._needDraw = true;
diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js
index 299f84ea4e..09b5db8416 100644
--- a/cocos2d/core/textures/CCTexture2D.js
+++ b/cocos2d/core/textures/CCTexture2D.js
@@ -427,6 +427,7 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
releaseTexture: function () {
if (this._gl && this._glID !== null) {
this._gl.deleteTexture(this._glID);
+ this._glID = null;
}
},
From 06b1965b8c4afd347218070b10ae5e990d79a1a4 Mon Sep 17 00:00:00 2001
From: SijieWang
Date: Mon, 7 May 2018 17:21:31 +0800
Subject: [PATCH 10/35] sizeProvider.visible needs to be updated
---
cocos2d/core/CCNode.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 6f61247562..366e8b2806 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -2529,6 +2529,7 @@ var Node = cc.Class({
}
}
}
+ sizeProvider.visible = this.active;
}
var sgParent = this._parent && this._parent._sgNode;
From 0e854f3cc4ada815987ee60ca5f8dc48f60e897a Mon Sep 17 00:00:00 2001
From: SijieWang
Date: Mon, 7 May 2018 18:01:58 +0800
Subject: [PATCH 11/35] `active` must synchronize to component
---
cocos2d/core/CCNode.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 366e8b2806..2ef6fb8bca 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -2460,6 +2460,15 @@ var Node = cc.Class({
var self = this;
var sgNode = self._sgNode;
+ // `active` must synchronize to component
+ for (var i=0; i
Date: Mon, 7 May 2018 18:16:10 +0800
Subject: [PATCH 12/35] move code to onRestore
---
cocos2d/core/CCNode.js | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 2ef6fb8bca..86cf9acc93 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -2460,15 +2460,6 @@ var Node = cc.Class({
var self = this;
var sgNode = self._sgNode;
- // `active` must synchronize to component
- for (var i=0; i
Date: Tue, 8 May 2018 10:23:19 +0800
Subject: [PATCH 13/35] remove setTimeout when stop audio (#2639)
---
cocos2d/audio/CCAudio.js | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index 70e20bc8c6..d8d91aa9ef 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -204,17 +204,9 @@ Audio.State = {
proto.stop = function () {
if (!this._element) return;
- if (CC_WECHATGAME) {
- setTimeout(function () {
- try {
- this._element.currentTime = 0;
- } catch (error) {}
- }.bind(this), 0);
- } else {
- try {
- this._element.currentTime = 0;
- } catch (error) {}
- }
+ try {
+ this._element.currentTime = 0;
+ } catch (error) {}
this._element.pause();
// remove touchPlayList
for (var i=0; i
Date: Tue, 8 May 2018 11:14:16 +0800
Subject: [PATCH 14/35] optimization label memory on qqplay and wechatgame
(#2643)
---
cocos2d/core/label/CCSGLabel.js | 6 ++----
cocos2d/core/label/CCSGLabelCanvasRenderCmd.js | 2 +-
cocos2d/core/label/CCSGLabelWebGLRenderCmd.js | 8 +++++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index 564c4a2c7b..acb90e6ad8 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -157,7 +157,7 @@ _ccsg.Label = _ccsg.Node.extend({
_ccsg.Node.prototype.ctor.call(this);
this.setAnchorPoint(0.5, 0.5);
- _ccsg.Node.prototype.setContentSize.call(this, 128, 128);
+ _ccsg.Node.prototype.setContentSize.call(this, 10, 10);
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
this._imageOffset = cc.p(0, 0);
@@ -1270,8 +1270,6 @@ _ccsg.Label.pool = new JS.Pool(function (label) {
label._fontHandle = "";
label._labelType = 0;
label._resetBMFont();
- label._renderCmd._labelCanvas.width = 1;
- label._renderCmd._labelCanvas.height = 1;
label._renderCmd._texture.releaseTexture();
if (CC_DEV) {
cc.assert(!label._parent, 'Recycling label\'s parent should be null!');
@@ -1294,7 +1292,7 @@ _ccsg.Label.pool.get = function (string, fontAsset) {
label._position.x = 0;
label._position.y = 0;
label.setAnchorPoint(0.5, 0.5);
- _ccsg.Node.prototype.setContentSize.call(label, 128, 128);
+ _ccsg.Node.prototype.setContentSize.call(label, 10, 10);
if (isAsset) {
label.setFontAsset(fontAsset);
diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
index 3902eb1402..41db589143 100644
--- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
@@ -399,7 +399,7 @@
};
proto._updateTexture = function() {
- this._labelContext.clearRect(0, 0, this._labelCanvas.width, this._labelCanvas.height);
+ this._labelContext.clearRect(0, 0, this._canvasSize.width, this._canvasSize.height);
this._labelContext.font = this._fontDesc;
diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
index 81165fb542..fa3fc6f2f6 100644
--- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
@@ -30,12 +30,14 @@
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
+var _sharedLabelCanvas;
_ccsg.Label.WebGLRenderCmd = function(renderableObject){
this._rootCtor(renderableObject);
this._needDraw = true;
this._texture = new cc.Texture2D();
- this._labelCanvas = document.createElement("canvas");
+ _sharedLabelCanvas = _sharedLabelCanvas || document.createElement('canvas');
+ this._labelCanvas = _sharedLabelCanvas;
this._texture.initWithElement(this._labelCanvas);
this._labelContext = this._labelCanvas.getContext("2d");
@@ -65,8 +67,8 @@ proto.updateTransform = function (parentCmd) {
this.originUpdateTransform(parentCmd);
var node = this._node,
- lx = 0, rx = this._labelCanvas.width,
- by = 0, ty = this._labelCanvas.height,
+ lx = 0, rx = this._node.width,
+ by = 0, ty = this._node.height,
wt = this._worldTransform;
var vert = this._vertices;
From b400e4b56f0236a8aca2d352714ccb4ab78a93d5 Mon Sep 17 00:00:00 2001
From: SijieWang
Date: Tue, 8 May 2018 11:50:41 +0800
Subject: [PATCH 15/35] review code
---
cocos2d/core/CCNode.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 86cf9acc93..8b638b998f 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -2505,13 +2505,13 @@ var Node = cc.Class({
_removeSgNode: SgHelper.removeSgNode,
onRestore: CC_EDITOR && function () {
- // `active` must synchronize to component
+ // update dummy sgNode of components
for (var i=0; i
Date: Tue, 8 May 2018 15:53:11 +0800
Subject: [PATCH 16/35] fix AudioSource load error. (#2616)
* fix AudioSource load error.
* release spriteFrame when you set a null value.
* fix audio preload error, more preload call will not create more WebAudioElement yet.
---
cocos2d/audio/CCAudio.js | 3 +++
cocos2d/core/components/CCAudioSource.js | 2 +-
cocos2d/core/components/CCSprite.js | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index d8d91aa9ef..9812dad57b 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -96,6 +96,9 @@ Audio.State = {
this._loaded = false;
return;
}
+
+ if (this._element)
+ return;
var item = cc.loader.getItem(src);
diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js
index c33a73bc98..0c881b8cef 100644
--- a/cocos2d/core/components/CCAudioSource.js
+++ b/cocos2d/core/components/CCAudioSource.js
@@ -215,7 +215,7 @@ var AudioSource = cc.Class({
if ( this.playOnLoad ) {
this.play();
}
- if ( this.preload ) {
+ else if ( this.preload ) {
this.audio.src = this._clip;
this.audio.preload();
}
diff --git a/cocos2d/core/components/CCSprite.js b/cocos2d/core/components/CCSprite.js
index 4889beb391..16901d2e48 100644
--- a/cocos2d/core/components/CCSprite.js
+++ b/cocos2d/core/components/CCSprite.js
@@ -564,6 +564,7 @@ var Sprite = cc.Class({
}
}
else {
+ sgNode.setSpriteFrame(null);
sgNode.setVisible(false);
}
From 3419688d1d68d01201024749c3ab5d761576ee0f Mon Sep 17 00:00:00 2001
From: knox
Date: Wed, 9 May 2018 11:27:43 +0800
Subject: [PATCH 17/35] fix ParticleSystem and update EngineErrorMap
---
EngineErrorMap.md | 3 +--
cocos2d/audio/CCAudioEngine.js | 4 ++--
cocos2d/core/components/CCAudioSource.js | 2 +-
cocos2d/particle/CCParticleSystem.js | 5 +++++
jsb/jsb-audio.js | 4 ++--
5 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/EngineErrorMap.md b/EngineErrorMap.md
index df6172210c..597afae9ca 100644
--- a/EngineErrorMap.md
+++ b/EngineErrorMap.md
@@ -2577,5 +2577,4 @@ Wrong type arguments, 'filePath' must be a String.
### 8401
-Since 1.10, `%s` accept cc.AudioClip instance directly, not a URL string. Please directly reference the AudioClip object in your script, or load cc.AudioClip by loader first. Don't use audio's URL anymore.
-
+Since 1.10, `%s` accept %s instance directly, not a URL string. Please directly reference the %s object in your script, or load %s by loader first. Don't use %s's URL anymore.",
diff --git a/cocos2d/audio/CCAudioEngine.js b/cocos2d/audio/CCAudioEngine.js
index 5752447c94..0ed91445c4 100644
--- a/cocos2d/audio/CCAudioEngine.js
+++ b/cocos2d/audio/CCAudioEngine.js
@@ -105,7 +105,7 @@ var audioEngine = {
var audio;
if (typeof clip === 'string') {
// backward compatibility since 1.10
- cc.warnID(8401, 'cc.audioEngine');
+ cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
path = clip;
// load clip
audio = getAudioFromPath(path);
@@ -426,7 +426,7 @@ var audioEngine = {
var filePath = clip;
if (typeof clip === 'string') {
// backward compatibility since 1.10
- cc.warnID(8401, 'cc.audioEngine');
+ cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
filePath = clip;
}
else {
diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js
index f08eab11c0..e178d96454 100644
--- a/cocos2d/core/components/CCAudioSource.js
+++ b/cocos2d/core/components/CCAudioSource.js
@@ -95,7 +95,7 @@ var AudioSource = cc.Class({
set: function (value) {
if (typeof value === 'string') {
// backward compatibility since 1.10
- cc.warnID(8401, 'cc.AudioSource');
+ cc.warnID(8401, 'cc.AudioSource', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
let self = this;
AudioClip._loadByUrl(value, function (err, clip) {
if (clip) {
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index b8c8895404..dcbf9611ed 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -160,6 +160,11 @@ var properties = {
return this._file;
},
set: function (value, force) {
+ if (typeof value === 'string') {
+ // backward compatibility since 1.10
+ cc.errorID(8401, 'cc.ParticleSystem', 'cc.ParticleAsset', 'ParticleAsset', 'cc.ParticleAsset', 'particle');
+ value = { nativeUrl: value };
+ }
if (this._file !== value || (CC_EDITOR && force)) {
this._file = value;
if (value) {
diff --git a/jsb/jsb-audio.js b/jsb/jsb-audio.js
index 52b7b600b3..4d1f7bc7fb 100644
--- a/jsb/jsb-audio.js
+++ b/jsb/jsb-audio.js
@@ -113,7 +113,7 @@ cc.Audio = function (src) {
var path;
if (typeof clip === 'string') {
// backward compatibility since 1.10
- cc.warnID(8401, 'cc.audioEngine');
+ cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
path = clip;
}
else {
@@ -203,7 +203,7 @@ cc.Audio = function (src) {
var path;
if (typeof clip === 'string') {
// backward compatibility since 1.10
- cc.warnID(8401, 'cc.audioEngine');
+ cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
path = clip;
}
else {
From ff5d765917f5214355e311ec13c4dd3b1396c1ca Mon Sep 17 00:00:00 2001
From: Jare Guo
Date: Wed, 9 May 2018 11:42:16 +0800
Subject: [PATCH 18/35] fix jsb-audio (#2649)
---
jsb/jsb-audio.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/jsb/jsb-audio.js b/jsb/jsb-audio.js
index 52b7b600b3..9fc7351873 100644
--- a/jsb/jsb-audio.js
+++ b/jsb/jsb-audio.js
@@ -122,7 +122,10 @@ cc.Audio = function (src) {
}
path = clip._nativeAsset;
}
- path = cc.loader.md5Pipe.transformURL(path);
+ var md5Pipe = cc.loader.md5Pipe;
+ if (md5Pipe) {
+ path = md5Pipe.transformURL(path);
+ }
return audioEngine.play2d(path, loop, volume);
};
audioEngine.playMusic = function (clip, loop) {
From e98d176f3693bca1bece7e8f486ad534ffc0437f Mon Sep 17 00:00:00 2001
From: knox
Date: Wed, 9 May 2018 11:51:19 +0800
Subject: [PATCH 19/35] refine EngineErrorMap.md
---
EngineErrorMap.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EngineErrorMap.md b/EngineErrorMap.md
index 597afae9ca..7a3ca2ffbc 100644
--- a/EngineErrorMap.md
+++ b/EngineErrorMap.md
@@ -2577,4 +2577,4 @@ Wrong type arguments, 'filePath' must be a String.
### 8401
-Since 1.10, `%s` accept %s instance directly, not a URL string. Please directly reference the %s object in your script, or load %s by loader first. Don't use %s's URL anymore.",
+Since 1.10, `%s` accept %s instance directly, not a URL string. Please directly reference the %s object in your script, or load %s by loader first. Don't use %s's URL anymore.
From 904ea1056a21e276e7f9779ee4256573242f4e24 Mon Sep 17 00:00:00 2001
From: knox
Date: Wed, 9 May 2018 15:39:12 +0800
Subject: [PATCH 20/35] fix label display error for fireball/issues/7233
---
cocos2d/core/label/CCSGLabelCanvasRenderCmd.js | 3 +--
cocos2d/core/label/CCSGLabelWebGLRenderCmd.js | 6 ++++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
index 53a40c659b..030600f535 100644
--- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
@@ -448,8 +448,7 @@
this._texture.loaded = false;
// Hack. because we delete _image after usage in WEBGL mode
- this._texture._image = this._labelCanvas;
- this._texture.handleLoadedTexture(true);
+ this._texture._nativeAsset = this._labelCanvas;
};
proto._getGradientArgs = function () {
diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
index a5bb34016d..a571e83ed5 100644
--- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
@@ -31,12 +31,18 @@
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
+//
+var opts = {
+ premultiplyAlpha: true
+};
+
var _sharedLabelCanvas;
_ccsg.Label.WebGLRenderCmd = function(renderableObject){
this._rootCtor(renderableObject);
this._needDraw = true;
this._texture = new cc.Texture2D();
+ this._texture.update(opts);
_sharedLabelCanvas = _sharedLabelCanvas || document.createElement('canvas');
this._labelCanvas = _sharedLabelCanvas;
this._texture.initWithElement(this._labelCanvas);
From 36e9616ce569827d8d9d0bec81c4a6a70396cbee Mon Sep 17 00:00:00 2001
From: Jare Guo
Date: Wed, 9 May 2018 19:48:16 +0800
Subject: [PATCH 21/35] fix api doc
---
cocos2d/core/components/CCEditBox.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cocos2d/core/components/CCEditBox.js b/cocos2d/core/components/CCEditBox.js
index 72a187fe95..d1216eebfd 100644
--- a/cocos2d/core/components/CCEditBox.js
+++ b/cocos2d/core/components/CCEditBox.js
@@ -328,7 +328,7 @@ var EditBox = cc.Class({
/**
* !#en The font color of placeholder.
- * !#zh 输入框最大允许输入的字符个数。
+ * !#zh 输入框占位符的字体颜色。
* @property {Color} placeholderFontColor
*/
placeholderFontColor: {
From 174635b63086e4a91f661133b0141535af655070 Mon Sep 17 00:00:00 2001
From: Knox
Date: Thu, 10 May 2018 10:28:22 +0800
Subject: [PATCH 22/35] fix videoplay md5 err for fireball/issues/6755 (#2657)
* label texture releaseTexture changed _releaseTexture
* fix videoplay md5 err for fireball/issues/6755
* refine code
---
cocos2d/core/components/CCVideoPlayer.js | 14 ++++++++------
cocos2d/core/label/CCSGLabel.js | 2 +-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js
index c4ecdec904..50e16995f9 100644
--- a/cocos2d/core/components/CCVideoPlayer.js
+++ b/cocos2d/core/components/CCVideoPlayer.js
@@ -298,15 +298,17 @@ var VideoPlayer = cc.Class({
_updateVideoSource: function () {
var sgNode = this._sgNode;
+ let url = '';
if (this.resourceType === ResourceType.REMOTE) {
- if (cc.loader.md5Pipe) {
- this.remoteURL = cc.loader.md5Pipe.transformURL(this.remoteURL);
- }
- sgNode.setURL(this.remoteURL);
+ url = this.remoteURL;
}
- else {
- sgNode.setURL(this._clip.nativeUrl || '');
+ else if (this._clip) {
+ url = this._clip.nativeUrl || '';
}
+ if (url && cc.loader.md5Pipe) {
+ url = cc.loader.md5Pipe.transformURL(url);
+ }
+ sgNode.setURL(url);
},
_initSgNode: function () {
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index 1751b48237..3cbf5daa80 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -1271,7 +1271,7 @@ _ccsg.Label.pool = new JS.Pool(function (label) {
label._fontHandle = "";
label._labelType = 0;
label._resetBMFont();
- label._renderCmd._texture.releaseTexture();
+ label._renderCmd._texture._releaseTexture();
if (CC_DEV) {
cc.assert(!label._parent, 'Recycling label\'s parent should be null!');
}
From af02e776e46bd46dde20451bafa71266b2bc85e5 Mon Sep 17 00:00:00 2001
From: "yufang.wu" <2435731537@qq.com>
Date: Fri, 11 May 2018 14:10:28 +0800
Subject: [PATCH 23/35] Update loading-items.js (#2665)
---
cocos2d/core/load-pipeline/loading-items.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cocos2d/core/load-pipeline/loading-items.js b/cocos2d/core/load-pipeline/loading-items.js
index 1aaf32e566..8bc1380a4f 100644
--- a/cocos2d/core/load-pipeline/loading-items.js
+++ b/cocos2d/core/load-pipeline/loading-items.js
@@ -124,7 +124,7 @@ function checkCircleReference(owner, item, recursiveCall) {
/**
* !#en
* LoadingItems is the queue of items which can flow them into the loading pipeline.
- * Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
+ * Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.
* It hold a map of items, each entry in the map is a url to object key value pair.
* Each item always contains the following property:
* - id: The identification of the item, usually it's identical to url
@@ -140,7 +140,7 @@ function checkCircleReference(owner, item, recursiveCall) {
* So please don't hold its reference for later usage, you can copy properties in it though.
* !#zh
* LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。
- * 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
+ * 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
* 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。
* 每个对象都会包含下列属性:
* - id:该对象的标识,通常与 url 相同。
@@ -298,7 +298,7 @@ LoadingItems.ItemState = new cc.Enum(ItemState);
* @param {Function} onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
* @return {LoadingItems} The LoadingItems queue obejct
* @example
- * LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
+ * cc.LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
* var progress = (100 * completedCount / totalCount).toFixed(2);
* cc.log(progress + '%');
* }, function (errors, items) {
From 7620bb93a2d0c1a717440d1d54820370b9be176c Mon Sep 17 00:00:00 2001
From: PP
Date: Tue, 15 May 2018 10:39:51 +0800
Subject: [PATCH 24/35] load ttf assets url with hashValue (#2652)
---
cocos2d/core/label/CCSGLabel.js | 2 +-
cocos2d/core/load-pipeline/md5-pipe.js | 22 ++++++++++++++--------
jsb/jsb-label.js | 2 +-
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index 3cbf5daa80..61bc8d611d 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -469,7 +469,7 @@ _ccsg.Label = _ccsg.Node.extend({
this.setFontFamily('');
return;
}
- var fontHandle = isAsset ? fontAsset.nativeUrl : '';
+ var fontHandle = cc.loader.md5Pipe ? cc.loader.md5Pipe.transformURL(fontAsset.nativeUrl, true) : fontAsset.nativeUrl;
var extName = cc.path.extname(fontHandle);
this._resetBMFont();
diff --git a/cocos2d/core/load-pipeline/md5-pipe.js b/cocos2d/core/load-pipeline/md5-pipe.js
index cb3e4ba937..0c2902d0a1 100644
--- a/cocos2d/core/load-pipeline/md5-pipe.js
+++ b/cocos2d/core/load-pipeline/md5-pipe.js
@@ -44,7 +44,7 @@ MD5Pipe.prototype.handle = function(item) {
return item;
};
-MD5Pipe.prototype.transformURL = function (url) {
+MD5Pipe.prototype.transformURL = function (url, hashPatchInFolder = false) {
var index = url.indexOf('?');
var key = url;
if (index !== -1) {
@@ -59,13 +59,19 @@ MD5Pipe.prototype.transformURL = function (url) {
}
let hashValue = this.md5AssetsMap[key];
if (hashValue) {
- var matched = false;
- url = url.replace(ExtnameRegex, function(match, p1) {
- matched = true;
- return '.' + hashValue + p1;
- });
- if (!matched) {
- url = url + '.' + hashValue;
+ if (hashPatchInFolder) {
+ var dirname = cc.path.dirname(url);
+ var basename = cc.path.basename(url);
+ url = `${dirname}.${hashValue}/${basename}`;
+ } else {
+ var matched = false;
+ url = url.replace(ExtnameRegex, (function(match, p1) {
+ matched = true;
+ return "." + hashValue + p1;
+ }));
+ if (!matched) {
+ url = url + "." + hashValue
+ }
}
}
return url;
diff --git a/jsb/jsb-label.js b/jsb/jsb-label.js
index c873bbf1e9..2b25e9e41d 100644
--- a/jsb/jsb-label.js
+++ b/jsb/jsb-label.js
@@ -307,6 +307,6 @@ cc.Label.pool.get = function (string, fontAsset, spriteFrame, fontSize) {
if (!isAsset) {
return new _ccsg.Label(string, null, null, fontSize);
}
- var fontHandle = isAsset ? fontAsset.nativeUrl : '';
+ var fontHandle = cc.loader.md5Pipe ? cc.loader.md5Pipe.transformURL(fontAsset.nativeUrl, true) : fontAsset.nativeUrl;
return new _ccsg.Label(string, fontHandle, spriteFrame, fontSize);
};
From 5c9ac688eec618d90bd52d9b7cef8dda47899eb1 Mon Sep 17 00:00:00 2001
From: Coco
Date: Wed, 16 May 2018 09:52:58 +0800
Subject: [PATCH 25/35] correct creator.d.ts little error
---
cocos2d/audio/CCAudioEngine.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cocos2d/audio/CCAudioEngine.js b/cocos2d/audio/CCAudioEngine.js
index 0ed91445c4..41082c7bac 100644
--- a/cocos2d/audio/CCAudioEngine.js
+++ b/cocos2d/audio/CCAudioEngine.js
@@ -597,7 +597,7 @@ var audioEngine = {
* !#en Resume playing background music.
* !#zh 恢复播放背景音乐。
* @method resumeMusic
- * //example
+ * @example
* cc.audioEngine.resumeMusic();
*/
resumeMusic: function () {
From 2156acf2ceac9b1c142e2f377c9bbe3eb24a4686 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E5=AE=B6=E8=BE=89?=
<35832931+ColinCollins@users.noreply.github.com>
Date: Wed, 16 May 2018 10:14:53 +0800
Subject: [PATCH 26/35] correct creator.d.ts little error (#2687)
---
cocos2d/audio/CCAudioEngine.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cocos2d/audio/CCAudioEngine.js b/cocos2d/audio/CCAudioEngine.js
index 0ed91445c4..41082c7bac 100644
--- a/cocos2d/audio/CCAudioEngine.js
+++ b/cocos2d/audio/CCAudioEngine.js
@@ -597,7 +597,7 @@ var audioEngine = {
* !#en Resume playing background music.
* !#zh 恢复播放背景音乐。
* @method resumeMusic
- * //example
+ * @example
* cc.audioEngine.resumeMusic();
*/
resumeMusic: function () {
From 70f24d9a6ca4e684b01e7728a97c6bf237d6aca1 Mon Sep 17 00:00:00 2001
From: Coco
Date: Wed, 16 May 2018 10:33:59 +0800
Subject: [PATCH 27/35] correct create creator.d.ts
---
cocos2d/actions/CCActionEase.js | 2 +-
cocos2d/audio/CCAudioEngine.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js
index c8d4cab1c6..75a62c67a7 100644
--- a/cocos2d/actions/CCActionEase.js
+++ b/cocos2d/actions/CCActionEase.js
@@ -2139,7 +2139,7 @@ cc._easeCircleActionOut = {
* 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCircleActionOut
* @returns {Object}
- * @exampple
+ * @example
* //example
* actioneasing(cc.easeCircleActionOut());
*/
diff --git a/cocos2d/audio/CCAudioEngine.js b/cocos2d/audio/CCAudioEngine.js
index 41082c7bac..9091912207 100644
--- a/cocos2d/audio/CCAudioEngine.js
+++ b/cocos2d/audio/CCAudioEngine.js
@@ -729,7 +729,7 @@ var audioEngine = {
* !#zh 恢复播放音效音频。
* @method resumeEffect
* @param {Number} audioID - The return value of function play.
- * //example
+ * @example
* cc.audioEngine.resumeEffect(audioID);
*/
resumeEffect: function (id) {
From 820c26906adf2c4800220accf06aaf00bad83b9a Mon Sep 17 00:00:00 2001
From: knox
Date: Thu, 17 May 2018 16:00:20 +0800
Subject: [PATCH 28/35] fix fireball/issues/7316
---
cocos2d/core/load-pipeline/pack-downloader.js | 14 ++++++++------
cocos2d/particle/CCSGParticleSystem.js | 1 +
modules.json | 3 +--
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/cocos2d/core/load-pipeline/pack-downloader.js b/cocos2d/core/load-pipeline/pack-downloader.js
index 6dcccf90ff..8305c76e9f 100644
--- a/cocos2d/core/load-pipeline/pack-downloader.js
+++ b/cocos2d/core/load-pipeline/pack-downloader.js
@@ -91,13 +91,15 @@ module.exports = {
},
_doPreload (packUuid, packJson) {
- var unpacker = globalUnpackers[packUuid];
- if (!unpacker) {
- unpacker = globalUnpackers[packUuid] = new JsonUnpacker();
+ var unpackerData = globalUnpackers[packUuid];
+ if (!unpackerData) {
+ unpackerData = globalUnpackers[packUuid] = new UnpackerData();
+ unpackerData.state = PackState.Downloading;
}
- if (unpacker.state !== PackState.Loaded) {
- unpacker.read(packIndices[packUuid], packJson);
- unpacker.state = PackState.Loaded;
+ if (unpackerData.state !== PackState.Loaded) {
+ unpackerData.unpacker = new Unpackers.JsonUnpacker();
+ unpackerData.unpacker.load(packIndices[packUuid], packJson);
+ unpackerData.state = PackState.Loaded;
}
},
diff --git a/cocos2d/particle/CCSGParticleSystem.js b/cocos2d/particle/CCSGParticleSystem.js
index 7c19fd2b5c..aecdc04132 100644
--- a/cocos2d/particle/CCSGParticleSystem.js
+++ b/cocos2d/particle/CCSGParticleSystem.js
@@ -27,6 +27,7 @@
var PNGReader = require('./CCPNGReader');
var tiffReader = require('./CCTIFFReader');
+require('../core/platform/CCSAXParser.js');
require('../compression/ZipUtils');
// ideas taken from:
diff --git a/modules.json b/modules.json
index fb01e89b87..3fae0c0a6c 100644
--- a/modules.json
+++ b/modules.json
@@ -46,8 +46,7 @@
"name": "ParticleSystem",
"entries": [
"./cocos2d/particle/CCParticleSystem.js",
- "./cocos2d/particle/CCParticleAsset.js",
- "./cocos2d/core/platform/CCSAXParser.js"
+ "./cocos2d/particle/CCParticleAsset.js"
]
},
{
From bc42a8a7cfc6efadc44ce7ef6e5a829bd9c1fee2 Mon Sep 17 00:00:00 2001
From: chenxianyin <420373550@qq.com>
Date: Mon, 21 May 2018 14:09:43 +0800
Subject: [PATCH 29/35] Issue fixes for audio preload and Scale9Sprite.FillType
(#2707)
* fix audio reload error, more preload call won't create more WebAudioElement yet.
* fix JSB cc.Scale9Sprite.FillType error.
---
cocos2d/audio/CCAudio.js | 3 +++
jsb/jsb-scale9sprite.js | 5 ++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index 9812dad57b..c6415d251c 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -100,6 +100,9 @@ Audio.State = {
if (this._element)
return;
+ if (this._element)
+ return;
+
var item = cc.loader.getItem(src);
if (!item) {
diff --git a/jsb/jsb-scale9sprite.js b/jsb/jsb-scale9sprite.js
index 95e509a44f..ffc00af613 100644
--- a/jsb/jsb-scale9sprite.js
+++ b/jsb/jsb-scale9sprite.js
@@ -59,9 +59,8 @@ cc.Scale9Sprite.RenderingType = cc.Enum({
});
cc.Scale9Sprite.FillType = cc.Enum({
- Horizontal: 0,
- Vertical: 1,
- //todo implement this
+ HORIZONTAL: 0,
+ VERTICAL: 1,
RADIAL:2,
});
From 29fa51c47b5b95e539719573a0c3ebfd03c1dff3 Mon Sep 17 00:00:00 2001
From: Knox
Date: Tue, 22 May 2018 10:20:09 +0800
Subject: [PATCH 30/35] fix audio bug in wxgame for fireball/issues/7325
(#2709)
* fix audio bug in wxgame for fireball/issues/7325
* update CC_WECHATGAME and CC_QQPLAY value
* refine CCAudio code
---
cocos2d/audio/CCAudio.js | 31 ++++++++++++------------
cocos2d/core/components/CCAudioSource.js | 6 ++---
predefine.js | 4 +--
3 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index 0bba8b3d52..a34a3a30c9 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -106,17 +106,18 @@ Audio.State = {
// };
proto._onLoaded = function () {
- if (this._src.loadMode === LoadMode.DOM_AUDIO) {
- if (CC_QQPLAY || CC_WECHATGAME) {
- this._element = elem;
- }
- else {
- this._element = document.createElement('audio');
- this._element.src = this._src._nativeAsset.src;
- }
+ var elem = this._src._nativeAsset;
+ if (CC_QQPLAY || CC_WECHATGAME) {
+ this._element = elem;
}
else {
- this._element = new WebAudioElement(this._src._nativeAsset, this);
+ if (this._src.loadMode === LoadMode.DOM_AUDIO) {
+ this._element = document.createElement('audio');
+ this._element.src = elem.src;
+ }
+ else {
+ this._element = new WebAudioElement(elem, this);
+ }
}
this.setVolume(this._volume);
@@ -162,9 +163,7 @@ Audio.State = {
};
proto.destroy = function () {
- if (CC_WECHATGAME) {
- this._element && this._element.destroy();
- }
+
};
proto.pause = function () {
@@ -257,9 +256,11 @@ Audio.State = {
};
proto.getState = function () {
- var elem = this._element;
- if (elem && Audio.State.PLAYING === this._state && elem.paused) {
- this._state = Audio.State.PAUSED;
+ if (!CC_WECHATGAME) {
+ var elem = this._element;
+ if (elem && Audio.State.PLAYING === this._state && elem.paused) {
+ this._state = Audio.State.PAUSED;
+ }
}
return this._state;
};
diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js
index e178d96454..ef9445a0b7 100644
--- a/cocos2d/core/components/CCAudioSource.js
+++ b/cocos2d/core/components/CCAudioSource.js
@@ -24,8 +24,8 @@
THE SOFTWARE.
****************************************************************************/
+const Audio = require('../../audio/CCAudio');
const AudioClip = require('../assets/CCAudioClip');
-require('../../audio/CCAudio');
/**
* !#en Audio Source.
@@ -33,8 +33,6 @@ require('../../audio/CCAudio');
* @class AudioSource
* @extends Component
*/
-
-
var AudioSource = cc.Class({
name: 'cc.AudioSource',
extends: require('./CCComponent'),
@@ -45,7 +43,7 @@ var AudioSource = cc.Class({
},
ctor: function () {
- this.audio = new cc.Audio();
+ this.audio = new Audio();
},
properties: {
diff --git a/predefine.js b/predefine.js
index e709dba050..8b9bd0befe 100644
--- a/predefine.js
+++ b/predefine.js
@@ -132,8 +132,8 @@ defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
defineMacro('CC_JSB', defined('jsb'));
defineMacro('CC_BUILD', false);
-defineMacro('CC_WECHATGAME', false);
-defineMacro('CC_QQPLAY', false);
+defineMacro('CC_WECHATGAME', defined('wx') && wx.getSystemInfoSync);
+defineMacro('CC_QQPLAY', defined('bk'));
defineMacro('CC_SUPPORT_JIT', !(CC_WECHATGAME || CC_QQPLAY));
//
From fae2cfceabf2593bcaec27d9b5cf1c6c68ff0617 Mon Sep 17 00:00:00 2001
From: Knox
Date: Tue, 22 May 2018 15:42:15 +0800
Subject: [PATCH 31/35] fix fireball/issues/7323, loading image should return
an image resource (#2712)
---
cocos2d/core/textures/CCTexture2D.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js
index d33d8f7a5e..8c0f46b9f7 100644
--- a/cocos2d/core/textures/CCTexture2D.js
+++ b/cocos2d/core/textures/CCTexture2D.js
@@ -407,7 +407,8 @@ var Texture2D = cc.Class({
// load image
var self = this;
cc.loader.load({
- url: this.url
+ url: this.url,
+ _owner: this
}, function (err, image) {
if (image) {
if (CC_DEBUG && image instanceof cc.Texture2D) {
From 3926c447d40881e919de9e3e12998dc191d9cc65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=84=E5=AE=B6=E8=BE=89?=
<35832931+ColinCollins@users.noreply.github.com>
Date: Tue, 22 May 2018 19:53:40 +0800
Subject: [PATCH 32/35] correct the note of getManifold function (#2708)
---
cocos2d/core/physics/CCPhysicsContact.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cocos2d/core/physics/CCPhysicsContact.js b/cocos2d/core/physics/CCPhysicsContact.js
index f7fd3d1f32..ca59c11d8c 100644
--- a/cocos2d/core/physics/CCPhysicsContact.js
+++ b/cocos2d/core/physics/CCPhysicsContact.js
@@ -296,7 +296,7 @@ PhysicsContact.prototype.getWorldManifold = function () {
* !#en
* Get the manifold.
* !#zh
- * 获取世界坐标系下的碰撞信息。
+ * 获取本地(局部)坐标系下的碰撞信息。
* @method getManifold
* @return {Manifold}
*/
From 820f22f32d398965f0a3a77d2f7ab6e9e793bb8c Mon Sep 17 00:00:00 2001
From: PP
Date: Wed, 23 May 2018 11:51:07 +0800
Subject: [PATCH 33/35] load spine url with hashValue (#2711)
---
extensions/spine/Skeleton.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/spine/Skeleton.js b/extensions/spine/Skeleton.js
index e7cb33bb4b..30674fb5e8 100644
--- a/extensions/spine/Skeleton.js
+++ b/extensions/spine/Skeleton.js
@@ -396,7 +396,7 @@ sp.Skeleton = cc.Class({
cc.errorID(7504);
return null;
}
- var jsonFile = skeletonData.nativeUrl;
+ var jsonFile = cc.loader.md5Pipe ? cc.loader.md5Pipe.transformURL(skeletonData.nativeUrl, true) : skeletonData.nativeUrl;
var atlasText = skeletonData.atlasText;
if (!atlasText) {
cc.errorID(7508, skeletonData.name);
From 112f8a4e9d38c5984d420a35231d9b0346a64568 Mon Sep 17 00:00:00 2001
From: PP
Date: Wed, 23 May 2018 18:19:45 +0800
Subject: [PATCH 34/35] fix tiledMap relative texture path (#2724)
---
cocos2d/tilemap/CCTMXXMLParser.js | 1 +
cocos2d/tilemap/editor/tiled-map.js | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js
index 4cd2729394..9929ba7a1d 100644
--- a/cocos2d/tilemap/CCTMXXMLParser.js
+++ b/cocos2d/tilemap/CCTMXXMLParser.js
@@ -683,6 +683,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
var image = selTileset.getElementsByTagName('image')[0];
var imagename = image.getAttribute('source');
+ imagename.replace(/\\/g, '\/');
tileset.sourceImage = this._textures[imagename];
if (!tileset.sourceImage) {
cc.errorID(7221, imagename);
diff --git a/cocos2d/tilemap/editor/tiled-map.js b/cocos2d/tilemap/editor/tiled-map.js
index 1dc63d3191..efd6eec3f9 100644
--- a/cocos2d/tilemap/editor/tiled-map.js
+++ b/cocos2d/tilemap/editor/tiled-map.js
@@ -42,6 +42,7 @@ function searchDependFiles(tmxFile, tmxFileData, cb) {
var textures = [];
var tsxFiles = [];
+ var textureNames = [];
function parseTilesetImages(tilesetNode, sourcePath) {
var images = tilesetNode.getElementsByTagName('image');
for (var i = 0, n = images.length; i < n ; i++) {
@@ -49,6 +50,9 @@ function searchDependFiles(tmxFile, tmxFileData, cb) {
if (imageCfg) {
var imgPath = Path.join(Path.dirname(sourcePath), imageCfg);
textures.push(imgPath);
+ let textureName = Path.relative(Path.dirname(sourcePath), imgPath);
+ textureName = textureName.replace(/\\/g, '\/');
+ textureNames.push(textureName);
}
}
}
@@ -77,7 +81,7 @@ function searchDependFiles(tmxFile, tmxFileData, cb) {
parseTilesetImages(tileset, tmxFile);
}
- cb(null, { textures: textures, tsxFiles: tsxFiles });
+ cb(null, { textures, tsxFiles, textureNames });
}
const AssetRootUrl = 'db://assets/';
@@ -88,9 +92,10 @@ class TiledMapMeta extends CustomAssetMeta {
this._tmxData = '';
this._textures = [];
this._tsxFiles = [];
+ this._textureNames = [];
}
- static version () { return '2.0.0'; }
+ static version () { return '2.0.1'; }
static defaultType() { return 'tiled-map'; }
import (fspath, cb) {
@@ -107,6 +112,7 @@ class TiledMapMeta extends CustomAssetMeta {
this._textures = info.textures;
this._tsxFiles = info.tsxFiles;
+ this._textureNames = info.textureNames;
cb();
});
@@ -122,7 +128,7 @@ class TiledMapMeta extends CustomAssetMeta {
var uuid = db.fspathToUuid(p);
return uuid ? Editor.serialize.asAsset(uuid) : null;
});
- asset.textureNames = this._textures.map(p => Path.basename(p));
+ asset.textureNames = this._textureNames;
asset.tsxFiles = this._tsxFiles.map(p => {
var tsxPath = Path.join(Path.dirname(fspath), p);
var uuid = db.fspathToUuid(tsxPath);
From c498b8092ea780c66ce66ee2922ed712b9649462 Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Thu, 24 May 2018 19:13:30 +0800
Subject: [PATCH 35/35] Remove compatibility code
---
cocos2d/particle/CCParticleSystem.js | 5 -----
1 file changed, 5 deletions(-)
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index 7d6314e0c1..62518abf6d 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -188,11 +188,6 @@ var properties = {
return this._file;
},
set: function (value, force) {
- if (typeof value === 'string') {
- // backward compatibility since 1.10
- cc.errorID(8401, 'cc.ParticleSystem', 'cc.ParticleAsset', 'ParticleAsset', 'cc.ParticleAsset', 'particle');
- value = { nativeUrl: value };
- }
if (this._file !== value || (CC_EDITOR && force)) {
this._file = value;
if (value) {