You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

47 lines
885 B

  1. define([
  2. 'js/rendering/renderer'
  3. ], function (
  4. renderer
  5. ) {
  6. let scale = 40;
  7. return {
  8. type: 'particles',
  9. emitter: null,
  10. init: function (blueprint) {
  11. this.blueprint = this.blueprint || {};
  12. this.blueprint.pos = {
  13. x: (this.obj.x * scale) + (scale / 2),
  14. y: (this.obj.y * scale) + (scale / 2)
  15. };
  16. this.ttl = blueprint.ttl;
  17. this.emitter = renderer.buildEmitter(this.blueprint);
  18. },
  19. update: function () {
  20. if (this.ttl != null) {
  21. this.ttl--;
  22. if (this.ttl <= 0) {
  23. if (this.destroyObject)
  24. this.obj.destroyed = true;
  25. else
  26. this.destroyed = true;
  27. return;
  28. }
  29. }
  30. if (!this.emitter.emit)
  31. return;
  32. this.emitter.spawnPos.x = (this.obj.x * scale) + (scale / 2);
  33. this.emitter.spawnPos.y = (this.obj.y * scale) + (scale / 2);
  34. },
  35. destroy: function () {
  36. renderer.destroyEmitter(this.emitter);
  37. }
  38. };
  39. });