friedmr5 Posted July 10, 2017 Share Posted July 10, 2017 (edited) Hi, everyone. I've not been able to find any similar issues to mine, so I'm posting a new topic asking for help. I'm using Phaser 2.6.2 to develop a multiplayer web game. I want a particle emitter to start at the location of the player when a button is pressed, in an explosion. In create(), I have the following code: this.emitter = game.add.emitter(0, 0, 8); this.emitter.makeParticles('seeds'); this.emitter.gravity = 500; I ask the emitter to start later in a custom function called dump(), passing in the player's coordinates. Dump() is called by a function when the variable appleEaten is true and the player is on the right part of the screen. dump: function (x, y) { appleEaten = false; this.emitter.x = x; this.emitter.y = y; console.log(this.emitter.maxParticles); this.emitter.start(true, 1000, null, 8, 8); console.log(this.emitter.x + ", " + this.emitter.y + " is the emitter."); console.log(this.emitter.on); // this is returning false? The program correctly knows how many particles it should spew (8). The emitter is at the correct coordinates based on another console log. However, this.emitter.on console log always returns false. I have the same console log line running in update, and of course it's false every time there, too. Basically, the emitter just doesn't turn on, and I don't know why. I am not getting any errors in the console, either. Has anyone run into this, and/or does anyone have a suggestion on how to approach this? Thank you! EDIT: I load 'seeds' in another state, as with all of my images. When I try to add 'seeds' as an image in create, nothing shows up, and again, no error. I imagine these are separate issues, but I could be wrong. Edited July 10, 2017 by fpg246 Clarification Link to comment Share on other sites More sharing options...
Vvalent Posted July 10, 2017 Share Posted July 10, 2017 https://phaser.io/sandbox/edit/ydvRRdmb Your code appears to be working in the Phaser sandbox. Even if your texture was unavailable the emitter should still use the default texture "_missing", which is just a green square (as in the sandbox example). The "on" property of the emitter probably only reads as true if it is actively releasing particles, which yours is not because it is set to burst/explode. If I had to guess I'd say you might have a context issue, but that's just a shot in the dark. If you post the entire state including your create function I might be able to provide some better insights. Link to comment Share on other sites More sharing options...
samme Posted July 12, 2017 Share Posted July 12, 2017 Emitters are on only during a particle flow, not after an explosion. It's likely equivalent but I'd recommend using explode instead of start because it's simpler: this.emitter.explode(1000, 8); Try samme/phaser-debug-emitter. Link to comment Share on other sites More sharing options...
friedmr5 Posted July 12, 2017 Author Share Posted July 12, 2017 Update: problem solved by moving where the code was in relation to... the background. Thank you >_< Link to comment Share on other sites More sharing options...
Recommended Posts