hi, can someone help me in creating a health bar that is fixed to the edge of the screen. I’ve tried searching for tutorials, but I can’t find anything. I just want a bar at the edge of the screen that is fixed, I still haven’t written any code to calculate damage and all.
first one as someone already told you in forum is to use Lemur(or some other GUI lib) progress bar
second is to just use simple GUINode elements like Picture/Quad and resize it to simulate health percentage
last one i know is to use Shader to update texture as a progress/health in Any Shape you want like here: progress - YouTube
for sure there are more solutions but this ones are the one i know, and wiki contain GUI pages as i know so you can see. Generally for basic HUD you can just use GUINode where you just put some Picture(quads/boxes) to represent your visual HUD. Here link:
Here is progress bar system I did for TimePilot. It is a texture image that repeats and I used a shader to clip the texture based on percentage. It is simple. I just check the x location and discard part of the image. So I pass in a value as progressBar, so now if I should display that part of the image or not. So when it is 100% meaning full that gets a 1, texCoord ranges from 0 - 1. Meaning 1 is the full width of the image.
if (texCoord1.x > float(m_progressBar / 100.0))
discard;
No, I"m not. I’ve looked at it, but didn’t like the implementation of sprite sheets. I don’t like changing the texcoord every frame update, that is a ton of gpu update. I don’t do that. I change the texcoord inside the shader and pass in the frame number to use an calculate it in the vertex shader.
I didn’t see anything wrong with it. For my Time Pilot game, I did it a bit different from other 2d games. They use multiple layers to move one layer faster/slower than the other. I didn’t do that. I like Jmonkey do it for it, by putting my game into a 3d world. I put each layer at a different “Z” location, so it is drawn small or larger, and moves slower/faster based on that. So in the game, all the graphics are the same and the speed never changes for anything.
I also, force resolution even in “FULL SCREEN” so that you always have the “VERTICAL” screen appearance. so if the width is to wide, then it creates bars, I do this with “OFF SCREEN” frame buffer rendering to my frame buffer, and then display the FB onto the JMonkey screen and position it so it is centered.