Is it possible to change the width of a sprite without scaling it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

For example, maybe stretching?

Problem I am running into is this:

I can scale the sprite, but this causes distortion when moving around with a camera.

I know there are other ways to make a HP bar, could just use a image and add a custom draw method to scale for HP, shaders, etc. But, just curious if I am missing a setting.

On other engines I basically just changed the “width” of the 1x1 sprite, and it acted like you were stretching it, not scaling. (Like a repeating background image if you will)

:bust_in_silhouette: Reply From: rgrams

If your texture has the “Repeat” flag set, you turn on “Region”, and you set the region to larger than the size of the sprite, it will tile to fill that area.

Ohh, I see. Is that only for non-sprite atlases? Cause I use the region for cropping from my main sprite. I can just save that little red image out and use it separately I guess, wouldn’t hurt performance that much, right?

wombatTurkey | 2016-05-27 02:35

Oh, I’m an idiot! It doesn’t crop it out when set to repeat… My bad. Wow, thanks for your help @rgrams!

wombatTurkey | 2016-05-27 02:36

Dang, the distortion still happens. Even worse. I think It’s because my game sprite is so large… I have no idea, but repeat and scale causes distortion when moving on the camera. I think I’ll just try a separate file or use a sprite with a custom draw method to cut customally

wombatTurkey | 2016-05-27 02:42

Ah, yes I was assuming it was a single sprite.

Hmm, well I can’t really tell from your screenshot what distortion you’re talking about, though if it only shows up when moving that would explain it. :slight_smile: I don’t know why scaling wouldn’t work.

Personally, for a health bar I would just use the built in UI stuff, or a shader.

rgrams | 2016-05-27 12:26