ParticleEffect Rotation (#6323)
* Additive * ternary * copypasta I missed a total of 4 instances * anuke has spoken Co-authored-by: Lele567 <48808663+Lele567@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,8 @@ public class ParticleEffect extends Effect{
|
|||||||
public float spin = 0f;
|
public float spin = 0f;
|
||||||
/** Controls the initial and final sprite sizes. */
|
/** Controls the initial and final sprite sizes. */
|
||||||
public float sizeFrom = 2f, sizeTo = 0f;
|
public float sizeFrom = 2f, sizeTo = 0f;
|
||||||
|
/** Whether the rotation adds with the parent */
|
||||||
|
public boolean useRotation = true;
|
||||||
/** Rotation offset. */
|
/** Rotation offset. */
|
||||||
public float offset = 0;
|
public float offset = 0;
|
||||||
/** Sprite to draw. */
|
/** Sprite to draw. */
|
||||||
@@ -53,10 +55,11 @@ public class ParticleEffect extends Effect{
|
|||||||
public void render(EffectContainer e){
|
public void render(EffectContainer e){
|
||||||
if(tex == null) tex = Core.atlas.find(region);
|
if(tex == null) tex = Core.atlas.find(region);
|
||||||
|
|
||||||
|
float realRotation = (useRotation ? e.rotation : baseRotation);
|
||||||
float rawfin = e.fin();
|
float rawfin = e.fin();
|
||||||
float fin = e.fin(interp);
|
float fin = e.fin(interp);
|
||||||
float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2;
|
float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2;
|
||||||
float ox = e.x + Angles.trnsx(e.rotation, offsetX, offsetY), oy = e.y + Angles.trnsy(e.rotation, offsetX, offsetY);
|
float ox = e.x + Angles.trnsx(realRotation, offsetX, offsetY), oy = e.y + Angles.trnsy(realRotation, offsetX, offsetY);
|
||||||
|
|
||||||
Draw.color(colorFrom, colorTo, fin);
|
Draw.color(colorFrom, colorTo, fin);
|
||||||
Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor;
|
Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor;
|
||||||
@@ -68,7 +71,7 @@ public class ParticleEffect extends Effect{
|
|||||||
rand.setSeed(e.id);
|
rand.setSeed(e.id);
|
||||||
for(int i = 0; i < particles; i++){
|
for(int i = 0; i < particles; i++){
|
||||||
float l = length * fin + baseLength;
|
float l = length * fin + baseLength;
|
||||||
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
|
rv.trns(realRotation + rand.range(cone), !randLength ? l : rand.random(l));
|
||||||
float x = rv.x, y = rv.y;
|
float x = rv.x, y = rv.y;
|
||||||
|
|
||||||
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
|
Lines.lineAngle(ox + x, oy + y, Mathf.angle(x, y), len);
|
||||||
@@ -78,10 +81,10 @@ public class ParticleEffect extends Effect{
|
|||||||
rand.setSeed(e.id);
|
rand.setSeed(e.id);
|
||||||
for(int i = 0; i < particles; i++){
|
for(int i = 0; i < particles; i++){
|
||||||
float l = length * fin + baseLength;
|
float l = length * fin + baseLength;
|
||||||
rv.trns(e.rotation + rand.range(cone), !randLength ? l : rand.random(l));
|
rv.trns(realRotation + rand.range(cone), !randLength ? l : rand.random(l));
|
||||||
float x = rv.x, y = rv.y;
|
float x = rv.x, y = rv.y;
|
||||||
|
|
||||||
Draw.rect(tex, ox + x, oy + y, rad, rad, e.rotation + offset + e.time * spin);
|
Draw.rect(tex, ox + x, oy + y, rad, rad, realRotation + offset + e.time * spin);
|
||||||
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a);
|
Drawf.light(ox + x, oy + y, rad * lightScl, lightColor, lightOpacity * Draw.getColor().a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user