From d13481a3a5e7b1b26f9a27665b4ce80c87138e63 Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Mon, 14 Dec 2015 11:17:07 +0800 Subject: [PATCH 1/2] should return when motionPaths length is 0 --- cocos2d/animation/motion-path-helper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos2d/animation/motion-path-helper.js b/cocos2d/animation/motion-path-helper.js index 1f87b02b0d..438980fc96 100644 --- a/cocos2d/animation/motion-path-helper.js +++ b/cocos2d/animation/motion-path-helper.js @@ -163,7 +163,7 @@ Bezier.prototype.getUtoTmapping = function ( u, distance ) { //console.log('b' , i, low, high, Date.now()- time); - if ( arcLengths[ i ] == targetArcLength ) { + if ( arcLengths[ i ] === targetArcLength ) { var t = i / ( il - 1 ); return t; @@ -216,6 +216,10 @@ function sampleMotionPaths (motionPaths, data, duration, fps) { var values = data.values; + if (motionPaths.length === 0 || values.length === 0) { + return; + } + values = values.map(function (value) { return v2(value[0], value[1]); }); From faa34caa4b62342da06ecdffc662cdbdd26bb20e Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Mon, 14 Dec 2015 11:17:39 +0800 Subject: [PATCH 2/2] export Curve and Bezier helper --- cocos2d/animation/motion-path-helper.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/animation/motion-path-helper.js b/cocos2d/animation/motion-path-helper.js index 438980fc96..9196b340af 100644 --- a/cocos2d/animation/motion-path-helper.js +++ b/cocos2d/animation/motion-path-helper.js @@ -327,5 +327,7 @@ if (CC_TEST) { } module.exports = { - sampleMotionPaths: sampleMotionPaths + sampleMotionPaths: sampleMotionPaths, + Curve: Curve, + Bezier: Bezier };