fixed motion streak

This commit is contained in:
yinkaile
2018-01-17 16:30:54 +08:00
parent a0b6d5fdb2
commit 32323f203d
+8 -4
View File
@@ -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;