2
\$\begingroup\$

I am trying to achieve a certain kind of absorb effect within libgdx via the particle editor.

To be more descriptive: I want particles to spawn in a circle and then move towards the center point of that circle (and then disappear there).

I can of course spawn the particles in a circle, but then I cannot seem to find a way to make sure they all move toward a center point.

So my questions can be divided into two parts:

  • Is their any way I could use the particle editor to achieve this absorb effect I described?
  • If not, then what would the best way to achieve it in libgdx? Is their some way I could hack into the particle effect behavior itself and make this work?
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I would say that No, you can't do that easily with the particle editor. It would require the synchronisation of three values:

  • xOffset
  • yOffset
  • velocity

In the libGDX particle effect implementation these are generated using RangedNumericalValues and ScaledNumericalValue, and they provide a new value independently of each other. The offsets are ranged, so you can't even draw an elaborate sine-curve to get them to give you the values matching the velocity set by the angle property.

However; if you don't mind the tedious work of manually creating many emitters you can get something that's close to what you want. If you set the offsets and the angle up manually, and do one emitter per angle you can get something that looks like this:

Small particle effect

In this example I used four emitters, but you can with a little work get that up to as many as you need for your effect.

The effect file for the above example looks like this;

A000
- Delay -
active: false
- Duration - 
lowMin: 1000.0
lowMax: 1000.0
- Count - 
min: 0
max: 200
- Emission - 
lowMin: 0.0
lowMax: 0.0
highMin: 8.0
highMax: 8.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life - 
lowMin: 0.0
lowMax: 0.0
highMin: 2000.0
highMax: 2000.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Life Offset - 
active: false
- X Offset - 
active: true
lowMin: -128.0
lowMax: -128.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Offset - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Shape - 
shape: point
- Spawn Width - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale - 
lowMin: 0.0
lowMax: 0.0
highMin: 16.0
highMax: 16.0
relative: false
scalingCount: 6
scaling0: 0.0
scaling1: 0.23529412
scaling2: 1.0
scaling3: 1.0
scaling4: 0.7647059
scaling5: 0.0
timelineCount: 6
timeline0: 0.0
timeline1: 0.19863014
timeline2: 0.30821916
timeline3: 0.65068495
timeline4: 0.89726025
timeline5: 1.0
- Velocity - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 64.0
highMax: 64.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle - 
active: true
lowMin: -5.0
lowMax: 5.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 2
scaling0: 0.0
scaling1: 0.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation - 
active: false
- Wind - 
active: false
- Gravity - 
active: false
- Tint - 
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency - 
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options - 
attached: false
continuous: false
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle.png


A090
- Delay -
active: false
- Duration - 
lowMin: 1000.0
lowMax: 1000.0
- Count - 
min: 0
max: 200
- Emission - 
lowMin: 0.0
lowMax: 0.0
highMin: 8.0
highMax: 8.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life - 
lowMin: 0.0
lowMax: 0.0
highMin: 2000.0
highMax: 2000.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Life Offset - 
active: false
- X Offset - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Offset - 
active: true
lowMin: -128.0
lowMax: -128.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Shape - 
shape: point
- Spawn Width - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale - 
lowMin: 0.0
lowMax: 0.0
highMin: 16.0
highMax: 16.0
relative: false
scalingCount: 6
scaling0: 0.0
scaling1: 0.23529412
scaling2: 1.0
scaling3: 1.0
scaling4: 0.7647059
scaling5: 0.0
timelineCount: 6
timeline0: 0.0
timeline1: 0.19863014
timeline2: 0.30821916
timeline3: 0.65068495
timeline4: 0.89726025
timeline5: 1.0
- Velocity - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 64.0
highMax: 64.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle - 
active: true
lowMin: 85.0
lowMax: 95.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 2
scaling0: 0.0
scaling1: 0.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation - 
active: false
- Wind - 
active: false
- Gravity - 
active: false
- Tint - 
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency - 
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options - 
attached: false
continuous: false
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle.png


A180
- Delay -
active: false
- Duration - 
lowMin: 1000.0
lowMax: 1000.0
- Count - 
min: 0
max: 200
- Emission - 
lowMin: 0.0
lowMax: 0.0
highMin: 8.0
highMax: 8.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life - 
lowMin: 0.0
lowMax: 0.0
highMin: 2000.0
highMax: 2000.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Life Offset - 
active: false
- X Offset - 
active: true
lowMin: 128.0
lowMax: 128.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Offset - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Shape - 
shape: point
- Spawn Width - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale - 
lowMin: 0.0
lowMax: 0.0
highMin: 16.0
highMax: 16.0
relative: false
scalingCount: 6
scaling0: 0.0
scaling1: 0.23529412
scaling2: 1.0
scaling3: 1.0
scaling4: 0.7647059
scaling5: 0.0
timelineCount: 6
timeline0: 0.0
timeline1: 0.19863014
timeline2: 0.30821916
timeline3: 0.65068495
timeline4: 0.89726025
timeline5: 1.0
- Velocity - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 64.0
highMax: 64.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle - 
active: true
lowMin: 175.0
lowMax: 185.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 2
scaling0: 0.0
scaling1: 0.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation - 
active: false
- Wind - 
active: false
- Gravity - 
active: false
- Tint - 
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency - 
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options - 
attached: false
continuous: false
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle.png


A270
- Delay -
active: false
- Duration - 
lowMin: 1000.0
lowMax: 1000.0
- Count - 
min: 0
max: 200
- Emission - 
lowMin: 0.0
lowMax: 0.0
highMin: 8.0
highMax: 8.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life - 
lowMin: 0.0
lowMax: 0.0
highMin: 2000.0
highMax: 2000.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Life Offset - 
active: false
- X Offset - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Offset - 
active: true
lowMin: 128.0
lowMax: 128.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Shape - 
shape: point
- Spawn Width - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height - 
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale - 
lowMin: 0.0
lowMax: 0.0
highMin: 16.0
highMax: 16.0
relative: false
scalingCount: 6
scaling0: 0.0
scaling1: 0.23529412
scaling2: 1.0
scaling3: 1.0
scaling4: 0.7647059
scaling5: 0.0
timelineCount: 6
timeline0: 0.0
timeline1: 0.19863014
timeline2: 0.30821916
timeline3: 0.65068495
timeline4: 0.89726025
timeline5: 1.0
- Velocity - 
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 64.0
highMax: 64.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle - 
active: true
lowMin: 265.0
lowMax: 275.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 2
scaling0: 0.0
scaling1: 0.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation - 
active: false
- Wind - 
active: false
- Gravity - 
active: false
- Tint - 
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency - 
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options - 
attached: false
continuous: false
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle.png

As for the second question, if you can hack libGDX to do this for you, the answer is Yes, absolutely. Look at the ParticleEmitter class, particularly the activateParticle method. you could open up that for inheritance a bit allowing you to hook in to the position setting of the newly created particle. If you do that you could set the x and y offsets according to the angle value and then you can achieve the effect you're looking for.

This would mean you'd have to change libGDX source code, but since it's open that's easy enough.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .