From 32323f203d3d0fb6e7e289d25ca2fa9fda40b50b Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Wed, 17 Jan 2018 16:30:54 +0800 Subject: [PATCH] fixed motion streak --- cocos2d/motion-streak/CCMotionStreak.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index b7c1ba0e0b..d66ed20a56 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -159,6 +159,9 @@ var MotionStreak = cc.Class({ }, set: function (value) { this._texture = value; + + this._material = null; + this._activateMaterial(); }, type: cc.Texture2D, animatable: false, @@ -216,8 +219,8 @@ var MotionStreak = cc.Class({ _activateMaterial: function () { if (this._material) return; - let url = this._texture; - let texture = cc.textureUtil.loadImage(url); + let texture = this._texture;; + let url = texture.url; let material = renderer.materialUtil.get(url); // Get material @@ -235,6 +238,7 @@ var MotionStreak = cc.Class({ this._fadeDelta = 1/60; this._maxPoints = (0 | (this._fadeTime * 60)); this._numPoints = 0; + this.reset(); }, onFocusInEditor: CC_EDITOR && function () { @@ -322,8 +326,8 @@ var MotionStreak = cc.Class({ for (let i = numPoints * 2 - 1; i >= 0; i--) { let dest = i + seg*2; if (dest >= maxPoints*2) continue; - data[dest].x = data[i].x; - data[dest].y = data[i].y; + data[dest].x = data[i].x; + data[dest].y = data[i].y; } let lastx = lastPoint.x, lasty = lastPoint.y;