Search code examples
javaandroidlibgdxcoordinate-systems

How to use particle effects like mentioned?


I am developing a multi-platform game on android studio using libGDX library and java language.

The game requires the player to maneuver a main ship across 2D space using mouse input.

I am using the given ParticleEffect class in libGDX library to show its exhaust but there is a slight problem that looks like this...

This is the standing ship
and
This is when its moving upward

I need every particle to move only downwards respective to the ship regardless the ship is standing or moving.
This means that I need to add the change in (x,y) coordinates of ship into each particle of exhaust but the problem is that the (x,y) coordinates of that class are private and there is no function that lets me make any direct changes to the coordinates of individual particles.

How do I make that happen?


Solution

  • Not sure, if I understood the question right. But probably, you can solve your issue via marking the emitter as attached. In this case if you change draw coordinates of ParticleEffect from (x0,y0) to (x1,y1), then every particle, which is already emitted, will be moved by (x1-x0, y1-y0) as well.

    See the screenshot: Attachment option in libgdx ParticleEditor