Jump to content

Particle emitter never turns on?


fpg246
 Share

Recommended Posts

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 by fpg246
Clarification
Link to comment
Share on other sites

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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