Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle effect fade time #5948

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/src/mindustry/entities/effect/ParticleEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ParticleEffect extends Effect{
public float spin = 0f;
/** Controls the initial and final sprite sizes. */
public float sizeFrom = 2f, sizeTo = 0f;
/** Controls the amount of ticks the effect waits before changing size. */
public float sizeChangeStart = 0f;
/** Whether the rotation adds with the parent */
public boolean useRotation = true;
/** Rotation offset. */
Expand All @@ -51,6 +53,7 @@ public class ParticleEffect extends Effect{
@Override
public void init(){
clip = Math.max(clip, length + Math.max(sizeFrom, sizeTo));
sizeChangeStart = Mathf.clamp(sizeChangeStart, 0f, lifetime);
if(sizeInterp == null) sizeInterp = interp;
}

Expand All @@ -62,7 +65,7 @@ public void render(EffectContainer e){
int flip = casingFlip ? -Mathf.sign(e.rotation) : 1;
float rawfin = e.fin();
float fin = e.fin(interp);
float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2;
float rad = sizeInterp.apply(sizeFrom, sizeTo, Mathf.curve(rawfin, sizeChangeStart / lifetime, 1f)) * 2;
float ox = e.x + Angles.trnsx(realRotation, offsetX * flip, offsetY), oy = e.y + Angles.trnsy(realRotation, offsetX * flip, offsetY);

Draw.color(colorFrom, colorTo, fin);
Expand Down