I’m trying to mix two textures together. One is an empty health bar texture and the other the full counterpart. When the health bar is, say, half empty, there should be the right half of the empty bar and the left half of the full part on the screen.
I tried drawing both as seperate textures, but the clipping modes don’t include “align right” and “align left” (or at least non that I know of) so I can’t do that. Also tried declaring a new texture in code and filling it with pixels from the two textures, but it EATS up processor power, reducing my framerate from 500fps to 30fps. What should I do? Tnx in advance.
When it’s an healthbar, than don’t try to mix them. Instead of that just multiply. Draw the 2 textures, and than multiply the health texture/that texture that will be filling it up, by health. And if you don’t wan’t to deform the texture, than you have to make 3 textures. Background, the texture that will be filling it up and a texture that will hide the unfilled parts. Like the opposite. You won’t make the filling texture bigger, but you will make the hiding texture, that will be colored the same as the background smaller.
– David
I also found another way to do it. Just add a new style to your GUI skin, such as “full health” and set the normal state’s texture to the full health texture. do the same with the empty texture and another style. In the draw code, figure out the width of the full portion (let’s name it f). Set the “full health” style’s Border.left property to f (make sure others are zero) and draw a box which is f pixels wide using the full health style. Do the same for the empty health texture, only set Border.right instead. Works perfectly.