I want to animate UI elements, like HP bars, by moving and resizing them. How can I efficiently resize sprites every frame?

I am using the LibGDX framework.

  • 2
    \$\begingroup\$ A sprite? No. 23 thousand? Probably. \$\endgroup\$ – Vaillancourt Mar 26 '17 at 2:08
  • 1
    \$\begingroup\$ Would it be appropriate to edit this question to read as "How would I efficiently resize a sprite every frame?" so it can be answered cleanly? \$\endgroup\$ – MickLH Mar 26 '17 at 2:41

When creating your texture, fill in the 2nd parameter to tell LibGDX to generate a mipmap chain:

Texture tex = new Texture(Gdx.files.internal("image.png"), true);

Then enable mipmapping in the texture filter:

tex.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);

This approach is hardware accelerated and there is no drawback to drawing the image at different sizes every frame.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.