Files
cocos4/cocos/3d/framework/particle/burst.js
T
zxg0622 6d0ed8e19f fix particle bugs (#3705)
* add particle default property

* fix some bug
2019-01-08 11:58:10 +08:00

78 lines
1.8 KiB
JavaScript

import { repeat } from "../../../core/vmath";
import CurveRange from "./animator/curve-range";
import { CCClass } from "../../../core/data";
import { property, ccclass } from "../../../core/data/class-decorator";
@ccclass('cc.Burst')
export default class Burst {
@property
_time = 0;
get time() {
return this._time;
}
set time(val) {
this._time = val;
this._curTime = val;
}
@property
minCount = 30;
@property
maxCount = 30;
@property
_repeatCount = 1;
get repeatCount() {
return this._repeatCount;
}
set repeatCount(val) {
this._repeatCount = val;
this._remainingCount = val;
}
@property
repeatInterval = 1;
@property({
type: CurveRange
})
count = null;
constructor() {
this._remainingCount = 1;
this._curTime = 0.0;
}
update(psys, dt) {
if (psys.loop && this._remainingCount === 0) {
this._remainingCount = this._repeatCount;
this._curTime = this._time;
}
if (this._remainingCount > 0) {
let preFrameTime = repeat(psys._time - psys.startDelay.evaluate(), psys.duration) - dt;
preFrameTime = (preFrameTime > 0.0) ? preFrameTime : 0.0;
let curFrameTime = repeat(psys.time - psys.startDelay.evaluate(), psys.duration);
if (this._curTime >= preFrameTime && this._curTime < curFrameTime) {
psys.emit(this.count.evaluate(this._curTime / psys.duration));
this._curTime += this.repeatInterval;
--this._remainingCount;
}
}
}
}
// CCClass.fastDefine('cc.Burst', Burst, {
// _time: 0,
// minCount: 30,
// maxCount: 30,
// _repeatCount: 1,
// repeatInterval: 1,
// count: new CurveRange
// });