java - How to use timer with libgdx? -


i'm trying use gdx timer increment value repeatedly when use value inside label seems nothing happens , value stuck @ 0 , here code timer :

@override     public void show() {         stage = new stage();         gdx.input.setinputprocessor(stage);          skin skin = new skin(gdx.files.internal("gui/uiskin.json"));         table = new table(skin);         table.setfillparent(true);          atlas = new textureatlas("gui/atlas.pack");         skin2 = new skin(gdx.files.internal("gui/menuskin.json"), atlas);           draganddrop draganddrop = new draganddrop();            // tables          inventoryactor = new inventoryactor(new inventory(16, 3), draganddrop, skin, "game pad");         inventoryactor2 = new inventoryactor(new inventory(25), draganddrop, skin, "inventory pad");          // bc image          batch = new spritebatch();         texture = new texture(gdx.files.internal("et2.jpg"));          timer.schedule(new task(){             @override             public void run() {                 timing++;             }         }, 1);          heading = new label("good luck"+(timing++), skin2, "big");          //timer task           //timercount = new label("time : "+timing+" s",skin2, "small");           = new textbutton("back", skin2, "small");         back.addlistener(new clicklistener() {             @override             public void clicked(inputevent event, float x, float y) {                 ((game) gdx.app.getapplicationlistener()).setscreen(new gameoption());             }         });         back.pad(10);          table.add(heading).colspan(3).expandx().spacebottom(50).row();         table.add(inventoryactor2).uniformx().expandy().top().left().padleft(30);         table.add(inventoryactor).top().spaceleft(30);         table.add(back).bottom().right();         stage.addactor(table);        }   @override     public void render(float delta) {         gdx.gl.glclearcolor(0, 0, 0, 1);         gdx.gl.glclear(gl20.gl_color_buffer_bit | gl20.gl_depth_buffer_bit);          /*if (gdx.input.iskeypressed(input.keys.any_key)) {          }*/              batch.begin();             batch.draw(texture, 10, 10);             batch.end();          inventoryactor.setvisible(true);         inventoryactor2.setvisible(true);          stage.act(delta);         stage.draw();      } 

the problem is, never set labels text inside show() method. give initial text string in constructor, label doesn't know, timing has changed. should set labels text in render() before calling stage.draw().


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -