Fix trail sprite size with zoom.

This commit is contained in:
Paul Chote
2015-11-28 11:13:06 +00:00
parent f8b0674ccc
commit 7a9f27aa11
2 changed files with 6 additions and 3 deletions

View File

@@ -18,11 +18,13 @@ namespace OpenRA.Effects
readonly string palette; readonly string palette;
readonly Animation anim; readonly Animation anim;
readonly WPos pos; readonly WPos pos;
readonly bool scaleSizeWithZoom;
public SpriteEffect(WPos pos, World world, string image, string palette) public SpriteEffect(WPos pos, World world, string image, string palette, bool scaleSizeWithZoom = false)
{ {
this.pos = pos; this.pos = pos;
this.palette = palette; this.palette = palette;
this.scaleSizeWithZoom = scaleSizeWithZoom;
anim = new Animation(world, image); anim = new Animation(world, image);
anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this))); anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this)));
} }
@@ -34,7 +36,8 @@ namespace OpenRA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr) public IEnumerable<IRenderable> Render(WorldRenderer wr)
{ {
return anim.Render(pos, WVec.Zero, 0, wr.Palette(palette), 1f / wr.Viewport.Zoom); var zoom = scaleSizeWithZoom ? 1f / wr.Viewport.Zoom : 1f;
return anim.Render(pos, WVec.Zero, 0, wr.Palette(palette), zoom);
} }
} }
} }

View File

@@ -214,7 +214,7 @@ namespace OpenRA.Widgets
else if (o.TargetLocation != CPos.Zero) else if (o.TargetLocation != CPos.Zero)
{ {
var pos = world.Map.CenterOfCell(cell); var pos = world.Map.CenterOfCell(cell);
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "moveflash"))); world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "moveflash", true)));
flashed = true; flashed = true;
} }
} }