Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to add Progress bar with my game to display life of player but when i move down through DigitalOnScreen Control the black bar that i want to display is not displayed there. I want to display that bar when i move in any direction it should be constantly displayed Here progress bar as a image is displayed Here Progress bar is not displayed

share|improve this question
    
Usually, GUI items don't have a position in the world, rather just one in the camera space. a little more information about your actual code would be helpful. –  Vengarioth Apr 3 '13 at 5:28

1 Answer 1

up vote 1 down vote accepted

You can use HUD.when move your camera, hud is not move that stable.

HUD hud = new HUD();
yourCamera.setHUD(hud);

hud.attachChild(yourBar);

public class GameTest extends BaseGameActivity {
private Camera camera;
private Scene scene;
private HUD hud;

@Override
public Engine onLoadEngine() {
    camera = new Camera(0, 0, Helper.CAMERA_WIDTH, Helper.CAMERA_HEIGHT);
    EngineOptions engineOptions = new EngineOptions(true,
            ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(
                    Helper.CAMERA_WIDTH, Helper.CAMERA_HEIGHT), camera);
    return new Engine(engineOptions);
}

@Override
public void onLoadResources() {
}

@Override
public Scene onLoadScene() {
    scene = new Scene();
    hud = new HUD();
    camera.setHUD(hud);

    Sprite blackBar = new Sprite(posX, posY, yourRegion);
    hud.attachChild(blackBar);

    return scene;
}

@Override
public void onLoadComplete() {
}

}

share|improve this answer
    
Thanks for your answer But i am using Scene so i don't know how to use HUD with Scene. –  Maan Apr 3 '13 at 6:13
    
Thanks a lot. It's Working. –  Maan Apr 3 '13 at 6:22
    
@Maan hud is one of Entity like scene. You can attach or detach entity in hud. also i update my code it helpful you. –  Divyang Metalia Apr 3 '13 at 6:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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