From dc6ceeecf40c187a1a342b7f17e066c63737c86d Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 18 Jul 2016 21:23:55 +0800 Subject: [PATCH 1/6] should not disable widget if it is not a child of current editing animation --- cocos2d/core/base-ui/CCWidgetManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-ui/CCWidgetManager.js b/cocos2d/core/base-ui/CCWidgetManager.js index 5ea2b125b7..f216a1b251 100644 --- a/cocos2d/core/base-ui/CCWidgetManager.js +++ b/cocos2d/core/base-ui/CCWidgetManager.js @@ -183,11 +183,12 @@ function refreshScene () { } else { var i, node, nodes = widgetManager._nodesWithWidget, len = nodes.length; if (CC_EDITOR && _Scene.AnimUtils.curAnimState) { + var editingNode = _Scene.AnimUtils.curRootNode; // always check isAlignOnce because animation mode maybe changed for (i = len - 1; i >= 0; i--) { node = nodes[i]; var widget = node._widget; - if (widget.isAlignOnce) { + if (widget.isAlignOnce && node.isChildOf(editingNode)) { // widget contains in _nodesWithWidget should aligned at least once widget.enabled = false; } From ae8f7abebf9f58965a587bf171c94ee4a1d6350e Mon Sep 17 00:00:00 2001 From: knoxHuang <821686174@qq.com> Date: Wed, 20 Jul 2016 11:10:09 +0800 Subject: [PATCH 2/6] fix Bezier node's coordinates when no sync bug for #fireball/issues/3660 --- jsb/jsb-action.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsb/jsb-action.js b/jsb/jsb-action.js index f2f0659f6f..46cc8761d8 100644 --- a/jsb/jsb-action.js +++ b/jsb/jsb-action.js @@ -332,7 +332,8 @@ var actionUpdate = { 'FadeOut': syncOpacityUpdate, 'FadeTo': syncOpacityUpdate, 'TintTo': syncColorUpdate, - 'TintBy': syncColorUpdate + 'TintBy': syncColorUpdate, + 'BezierBy': syncPositionUpdate }; for (var key in actionUpdate) { From 6e13b1b6043666f1ec53c7f30102f6eacc6f6ed3 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 14:47:11 +0800 Subject: [PATCH 3/6] fix currentTime, add duration is isPlaying APIs --- cocos2d/core/components/CCVideoPlayer.js | 36 +++++++++++++++++---- cocos2d/core/videoplayer/CCSGVideoPlayer.js | 12 +++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js index 837369f585..f7d78ff1bc 100644 --- a/cocos2d/core/components/CCVideoPlayer.js +++ b/cocos2d/core/components/CCVideoPlayer.js @@ -147,21 +147,23 @@ var VideoPlayer = cc.Class({ url: cc.RawAsset }, - _time: 0, /** - * !#en The current time when video start to play. - * !#zh 从当前时间点开始播放视频 + * !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + * !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 * @property {Number} currentTime */ currentTime: { tooltip: 'i18n:COMPONENT.videoplayer.currentTime', type: cc.Float, set: function ( time ) { - this._time = time; - this._sgNode.seekTo(time); + if(this._sgNode) { + this._sgNode.seekTo(time); + } }, get: function () { - return this._time; + if(this._sgNode) { + return this._sgNode.currentTime(); + } } }, @@ -210,7 +212,6 @@ var VideoPlayer = cc.Class({ }, onLoad: function() { - if(CC_JSB) { if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) { this.enabled = false; @@ -318,6 +319,27 @@ var VideoPlayer = cc.Class({ } }, + /** + * !#en Gets the duration of the video + * !#zh 获取视频文件的播放总时长 + */ + getDuration: function() { + if(this._sgNode) { + this._sgNode.duration(); + } + }, + + /** + * !#en Determine whether video is playing or not. + * !#zh 判断当前视频是否处于播放状态 + */ + isPlaying: function() { + if(this._sgNode) { + return this._sgNode.isPlaying(); + } + return false; + } + }); cc.VideoPlayer = module.exports = VideoPlayer; diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js index 9ec0d6287f..ed81f7bc2e 100644 --- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js +++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js @@ -73,6 +73,10 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ return this._renderCmd.isPlaying(); }, + duration: function () { + return this._renderCmd.duration(); + }, + createDomElementIfNeeded: function () { if (!this._renderCmd._video) { this._renderCmd.createDom(); @@ -501,6 +505,7 @@ _ccsg.VideoPlayer.EventType = { }; proto.isPlaying = function () { + var video = this._video; if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation && this._playing){ setTimeout(function(){ video.play(); @@ -509,4 +514,11 @@ _ccsg.VideoPlayer.EventType = { return this._playing; }; + proto.duration = function () { + var video = this._video; + if(!video) return; + + return video.duration; + }; + })(_ccsg.VideoPlayer._polyfill); From 5e5b143308c6700090f274a2e305a0a891e0bf69 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 15:24:19 +0800 Subject: [PATCH 4/6] fix edge cases when using outline --- cocos2d/core/label/CCSGLabelCanvasRenderCmd.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js index 370f696a09..c96985fd4a 100644 --- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js @@ -117,10 +117,11 @@ maxWidth -= 2 * this._getMargin(); var wrappedWords = []; //fast return if strArr is empty - if(strArr.length === 0) { + if(strArr.length === 0 || maxWidth < 0) { wrappedWords.push(''); return wrappedWords; } + var text = strArr; var allWidth = ctx.measureText(text).width; while (allWidth > maxWidth && text.length > 1) { @@ -222,6 +223,11 @@ var canvasWidthNoMargin = this._canvasSize.width - 2 * this._getMargin(); var canvasHeightNoMargin = this._canvasSize.height - 2 * this._getMargin(); + if(canvasWidthNoMargin < 0 || canvasHeightNoMargin < 0) { + fontDesc = '1px ' + fontFamily; + this._labelContext.font = fontDesc; + return fontDesc; + } totalHeight = canvasHeightNoMargin + 1; maxLength = canvasWidthNoMargin + 1; var actualFontSize = this._drawFontsize + 1; @@ -251,7 +257,6 @@ textFragment = this._fragmentText(paragraphedStrings[i], canvasWidthNoMargin, this._labelContext); - var isBiggerSize = false; while(j < textFragment.length) { var measureWidth = this._labelContext.measureText(textFragment[j]).width; maxLength = measureWidth; From 5a5eda023dcc2a69583e731d67b89b0f4503c1d7 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 15:36:16 +0800 Subject: [PATCH 5/6] improve videoPlayer --- cocos2d/core/components/CCVideoPlayer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js index f7d78ff1bc..e7044779d3 100644 --- a/cocos2d/core/components/CCVideoPlayer.js +++ b/cocos2d/core/components/CCVideoPlayer.js @@ -164,6 +164,7 @@ var VideoPlayer = cc.Class({ if(this._sgNode) { return this._sgNode.currentTime(); } + return -1; } }, @@ -327,6 +328,7 @@ var VideoPlayer = cc.Class({ if(this._sgNode) { this._sgNode.duration(); } + return -1; }, /** From f6ec41cce48f8fcba398c3086b3f9f2011cba1a0 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 15:47:46 +0800 Subject: [PATCH 6/6] fix currentTime and duration --- cocos2d/core/components/CCVideoPlayer.js | 2 +- cocos2d/core/videoplayer/CCSGVideoPlayer.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js index e7044779d3..1de87bf61a 100644 --- a/cocos2d/core/components/CCVideoPlayer.js +++ b/cocos2d/core/components/CCVideoPlayer.js @@ -326,7 +326,7 @@ var VideoPlayer = cc.Class({ */ getDuration: function() { if(this._sgNode) { - this._sgNode.duration(); + return this._sgNode.duration(); } return -1; }, diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js index ed81f7bc2e..64dad7323e 100644 --- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js +++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js @@ -77,6 +77,10 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ return this._renderCmd.duration(); }, + currentTime: function() { + return this._renderCmd.currentTime(); + }, + createDomElementIfNeeded: function () { if (!this._renderCmd._video) { this._renderCmd.createDom(); @@ -516,9 +520,16 @@ _ccsg.VideoPlayer.EventType = { proto.duration = function () { var video = this._video; - if(!video) return; + if(!video) return -1; return video.duration; }; + proto.currentTime = function () { + var video = this._video; + if(!video) return -1; + + return video.currentTime; + }; + })(_ccsg.VideoPlayer._polyfill);