Jump to content

Emitter.Angle Question


dthompson714
 Share

Recommended Posts

Hello,

This forum has been a great source of knowledge as I work to create my first game with Phaser, Thank you!

 

My question is regarding the angle of an emitter. I have a sprite that moves from one object to another, think missile fire, and i have an emitter set up to create a 'trail' but I can't figure out how to get my missile trail to be the same angle as my missile.

 

Setting the emitter.angle (emitter.angle = 45;) seems to not only change the angle of the trail but also the path (and starting location) of the trail. It no longer follows the missile sprite.

Removing the angle everything works and the trail follows the sprite but the angle of the trail is incorrect.

 

Images show results of firing missile from white circle to random green circle.

First image shows emitter with no emitter.angle

Second image shows emitter with emitter.angle = 45; (notice that emitter particle is rotated 45 degrees but the path has also been offset by 45 degrees) 

 

Missile = Blue

Emitter = Pink

Not sure code was needed but can supply if helpful.

 

Any advise is appreciated,

Thank you.

post-12628-0-02309000-1421259056_thumb.p

post-12628-0-54390600-1421259057_thumb.p

Link to comment
Share on other sites

UPDATE:

 

I was able to achieve the effect I was looking for creating a Phaser.Line and then applying my 'trail' image with textureLine.

Would still like to know if there is a solution I can try to angle the emitter as I like the flexibility of using particles instead of the Phaser.Line

 

Thank you.

Link to comment
Share on other sites

Anyone feel free to correct me on this, but looking at the source code, it seems that particles always start with an angle of 0, and there seems to be no built-in way of changing this (if there were, this is the value you'll probably want to manipulate). As you have already observed, setting the emitter's angle doesn't accomplish what you intend, and this behavior is confirmed in the documentation. If you really want to use the Emitter class, you can add a property that will allow you to set a particle's starting angle (just add one line to Emitter.js) then use this value to set a particle's starting angle instead of 0, then set your particles' angular velocity to 0 so that they don't rotate.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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