I’m making a health bar for the game I’m working on. I followed the directions given in DirectGUI (DirectWaitBar)… to put textures for the background and fill.
My problem is that I want the bar to have a non-rectangular shape. I can set transparency on the background texture (I just called setTransparency on the health bar object). I can’t figure out what to call setTransparency on to get the fill to have transparency as well. (barStyle apparently does not have a setTransparency method)
Setting transparency on the healthBar should also serve to apply transparency to the background (since a child inherits the state of its parent). In fact, in my quick experiment, that works fine for me. The background texture also shows transparency.
Er, the background does show transparency, my problem is transparency for the foreground.
You can see that there’s transparency at the top of the bar, which is the background image, but not at the bottom, which is the “fill” (barStyle) image. (please excuse the programmer art)
Er, sorry. Yes. I get transparency on the foreground too. It shows through to the background texture. If you’re not seeing the background through the foreground bar, are you sure that your foreground texture has an alpha channel?
If I comment out the lines starting with ts = TextureStage.getDefault(), it looks like this:
(The second image is mostly so you can see what the textures actually look like.)
This code used to give me a proper filling health bar. Did I mess something up? (I did change frameSize and pos as well as frameTexture when I put in the new texture.)
The setTexProjector call will generate UV’s that basically stick the texture to the glass–so that if you move the bar around (by changing frameSize or framePos) it will leave the texture behind.
Your two options are (1) don’t use the setTexProjector, and let the texture naturally stretch to fill the size of the bar, or (2) continue to use setTexProjector, but adjust the tex transform to match the change you applied to the frame. I’d recommend using setTexOffset, setTexScale, and setTexRotate in lieu of the more awkward setTexTransform.