Jump to content

Particles spawning incorrectly when Emitter width/height is set


Recommended Posts

I wish I knew how to GitHub properly so I could do the whole Pull request thing.

I believe I am in the Dev branch.



Particles/Arcade/Emitter.js has one line that is breaking things when trying to use a width/height value on the emitter.


Line 361:

particle.reset(this.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom));

Problem 1: "this.emiteX" and "this.emiteY" should be "this.emitX" and "this.emitY".


Problem 2: this.game.rnd.integerInRange(this.left, this.right) and the top/bottom one too both return a value that results in the particles being centered around the origin, rather than the emitters X/Y position. This is because the integerInRange returns a value between the left(top) of the emitter and the right(bottom) of the emitter, and this value is then subtracted from where the emitter is.

Example: The emitter is at (300, 300) and is 10x10. The value returned by integerInRange will be somewhere in 290-310. This is subtracted from 300, leaving the particle to spawn in the -10 to 10 range, rather than the 290-310 range one would expect.

Possible solutions are to just remove the "this.emitX(Y) - " parts, solving problem 1 at the same time, or the more complicated one is changing the range to be "this.game.rnd.integerInRange(-this.width/2, this.width/2)".


For my version, I'm going with the first solution of removing this.emiteX(Y) entirely.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...