SubEmitter.ts 966 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import CustomParticle from "../index";
  2. /**
  3. * 粒子子发射器的依附状态。
  4. */
  5. export const enum SubEmitterState {
  6. /**
  7. * 依附于粒子整个生命周期
  8. */
  9. ATTACH = 0,
  10. /**
  11. * 在粒子生命周期末出现
  12. */
  13. END = 1
  14. }
  15. // 子发射器类
  16. export default class SubEmitter {
  17. public particleSystem: CustomParticle;
  18. public state: SubEmitterState;
  19. constructor(particleSystem) {
  20. this.particleSystem = particleSystem;
  21. this.state = SubEmitterState.END;
  22. }
  23. /**
  24. * 通过克隆,获取指定的粒子子发射器实例
  25. * @return {SubEmitter} 克隆后的子发射器实例
  26. */
  27. public clone() {
  28. var cloneParticleSystem = this.particleSystem.clone();
  29. cloneParticleSystem.initParticle(cloneParticleSystem.data);
  30. var cloneSubEmitter = new SubEmitter(cloneParticleSystem);
  31. cloneSubEmitter.state = this.state;
  32. return cloneSubEmitter;
  33. }
  34. }