Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED BY DERMETFAN] libgdx + Slider + Health/Mana Bar - How to + notWorking?  (Read 2458 times)
0 Members and 1 Guest are viewing this topic.
Offline Andre Lopes
« Posted 2013-07-21 17:55:17 »

Hi! Long time i dont post, well, i really did try to make this work, but im being unable to draw a slider at my table to make it like a health bar!
It doesnt give any errors but it still doesnt show up.

Can anyone give me a hand or some tips,please ?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
@Override
    public void render(float delta) {

        //Clear Screen
       Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        //Update Player Pos
       player.update(delta);

        //Set Camera Position
       camera.position.set((400f), (296f + 4f), 0f);
        camera.update();

        //Render
       //Add Camera to renderer
       renderer.setView(camera);

        renderer.render();
        renderer.getSpriteBatch().begin();
     
        player.draw(renderer.getSpriteBatch());

        renderer.getSpriteBatch().end();


       
        batch.begin();
          healthSlider.draw(batch, 0);
        batch.end();


        //Set First Layer to be drawn.
       //Theres no 2nd Layer yet
       //renderer.render(new int[]{1});
       //Draw Stage
       //Draw Table
       Table.drawDebug(stage);
        upperTable.debug();
        stage.act(delta);
        stage.draw();

    }

    @Override
    public void show() {
        batch = new SpriteBatch();
       
        int width = Gdx.graphics.getWidth();
        int height = Gdx.graphics.getHeight();

        //create of Table and Mountage {
       //Mount upperTable
       upperTable = new Table();
        bottomTable = new Table();
     
       
        float partialYpos = height - (height * 10f) / 100f;
        upperTable.setBounds(0f, partialYpos, width, height);
        partialYpos = height - (height * 95f) / 100f;
        bottomTable.setBounds(0f,0f,width,partialYpos);
        upperTable.debug();
        bottomTable.debug();
       
        //Instantiate THe Font
       simpleBlackFont = new BitmapFont(Gdx.files.internal("fonts/simpleBlackFont.fnt"), false);
       
        //Instantiate the Skin
       skin = new Skin();
        skin.add("knob", new Texture(Gdx.files.internal("imagens/Slider/knob.png")));
        skin.add("bgs", new Texture(Gdx.files.internal("imagens/Slider/backgroundSlider.png")));

        Slider.SliderStyle style = new Slider.SliderStyle();
        style.background = skin.getDrawable("bgs");
       
        healthSlider = new Slider(0, 100, 1, false, style);
        healthSlider.setVisible(true);
     
        upperTable.add(healthSlider);

        //Set up the Stage for the Table
       stage = new Stage();
        stage.addActor(upperTable);
        stage.addActor(bottomTable);
        //} end of Table Creation and mountage
       
       
        map = new TmxMapLoader().load("tmx/ArcherLevelOne.tmx");
        renderer = new OrthogonalTiledMapRenderer(map);
        camera = new OrthographicCamera();
        levelLayer = (TiledMapTileLayer) map.getLayers().get(0);
        player = new Player(new Sprite(new Texture(Gdx.files.internal("imagens/cTest.png"))), levelLayer);

        player.setPosition(levelLayer.getTileHeight() * 20 + player.getHeight(), levelLayer.getTileWidth() * 10 + player.getWidth());

        Gdx.input.setInputProcessor(player);

    }
Offline Andre Lopes
« Reply #1 - Posted 2013-07-22 18:32:42 »

ANyone have a tutorial abour progressBar in libgdx? Already read the wiki but.. Still doesnt work!
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #2 - Posted 2013-07-22 21:53:24 »

Seems you threw a bunch of stuff in all at once. Start with the examples and modify them to work like you want, then graft it into your game.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2013-07-22 23:19:05 »

Add features one at a time, and add those features a step at a time. Don't rush it, it'll just end up being a mess of code that only works in parts.
Offline dermetfan

Senior Member


Medals: 11



« Reply #4 - Posted 2013-07-22 23:29:49 »

1  
healthSlider.draw(batch, 0);

This makes the slider completely transparent. The second parameter should be 1, but you should use a stage anyway.

Offline Andre Lopes
« Reply #5 - Posted 2013-07-23 21:07:31 »

1  
healthSlider.draw(batch, 0);

This makes the slider completely transparent. The second parameter should be 1, but you should use a stage anyway.

Heya Dermet Tongue, still, without that line it should render itself since its in stage...

Btw, when i put 1 instead, it became drawned in screen but in middle. I wonder what im doing wrong Sad
Offline Syntax

Innocent Bystander





« Reply #6 - Posted 2014-01-19 14:47:27 »

Hi, here are my ProgressBars which I use.

ProgressBar
TextProgressBar

This is example how it looks like:
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (24 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!