mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fixed motion streak
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user