Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  
  Countdown timer problem in LIBGDX, last digit flickering.  (Read 803 times)
0 Members and 1 Guest are viewing this topic.
Offline assjiggler

Senior Newbie





« Posted 2014-07-09 23:57:15 »

the last digit of the printed out time on gameover always flickers.  like 4.51 to 4.53 to 4.51, i need it to just stop at one or the other, im so confused

public void render(float delta) {
      
      
      label.updateText("SCORE: "+toString(score));
      seconds.updateText(String.format("time: %,.2f", time));
       System.out.println(TimeUtils.millis()/1000);

      time-= delta;
      //time is started 10

      //if(time<=0.001)
          //  currentState = GameState.GAMEOVER;

      switch (currentState)
      {
      
      case RUNNING:
      {   
         
         Gdx.gl.glClearColor(0, 0 , 1, 1);
         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
         stage.act(delta);
         stage.draw();
         
      
      
      break;
      }
      
      case PAUSED:
      {
         System.out.println("pauseddd");
         break;
      }
      
      case GAMEOVER:
      {         
         go.setPosition(200,400);         
         stage2.act(delta);
         stage2.draw();
         break;
      }
      
      default:
            break;      
      }
   }
Offline assjiggler

Senior Newbie





« Reply #1 - Posted 2014-07-10 02:20:53 »

anyone? no ideas?
Offline temu

Senior Newbie


Medals: 1
Exp: 2 years



« Reply #2 - Posted 2014-07-10 02:31:40 »

anyone? no ideas?

I guess it may be some sort of annoying bug related to your instuction time -= delta.
Maybe you change the time value in other parts of your code and it continues changing?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline assjiggler

Senior Newbie





« Reply #3 - Posted 2014-07-10 15:28:49 »

anyone? no ideas?

I guess it may be some sort of annoying bug related to your instuction time -= delta.
Maybe you change the time value in other parts of your code and it continues changing?

i was thinking the same thing but time doesnt get changed anywhere else, is there any other way to make a countdown timer then? just want to deciamla places to appear
Offline temu

Senior Newbie


Medals: 1
Exp: 2 years



« Reply #4 - Posted 2014-07-10 17:04:49 »

i was thinking the same thing but time doesnt get changed anywhere else, is there any other way to make a countdown timer then? just want to deciamla places to appear

I think you can use java.util.Timer
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2014-07-10 21:12:46 »

Print out 'delta' & 'time'.

Assuming 'delta' is always > 0.0, 'time' can only decrease, so if 'time' is alternating, something else *is* modifying it, or your 'delta' is negative / alternating. That's why you print out 'delta' too.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline assjiggler

Senior Newbie





« Reply #6 - Posted 2014-07-10 21:49:10 »

it becomes E when i move the mouse around . ive been on this problem for days. this bites

heres a list of deltas:
0.005420111
0.016723463
0.03341151
5.382E-4
0.03283135
4.22706E-4
0.032908726
3.5033E-4
0.03335415
6.67553E-4
0.015830697
0.01635966
0.016776204
0.016737709
0.016584488
0.01668458
0.016746178
0.016641848
0.0166226
0.033428065
6.62933E-4
0.036291532
4.75834E-4
0.029283
3.53025E-4
0.033733737
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2014-07-10 22:03:36 »

So delta is never below zero - this means that 'time' can only be decreasing. If it's not, something else is modifying it...

Again:
Print out 'delta' & 'time'.
Not just delta.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline assjiggler

Senior Newbie





« Reply #8 - Posted 2014-07-10 22:05:42 »

So delta is never below zero - this means that 'time' can only be decreasing. If it's not, something else is modifying it...

Again:
Print out 'delta' & 'time'.
Not just delta.

Sryy heres both:

delta : 0.00454929 time: 10.0
delta : 0.006650118 time: 9.995451
delta : 0.020421183 time: 9.988801
delta : 0.012100642 time: 9.96838
delta : 0.018331135 time: 9.95628
delta : 0.015077681 time: 9.937948
delta : 0.016591031 time: 9.922871
delta : 0.016045902 time: 9.90628
delta : 0.016974084 time: 9.890234
delta : 0.016981784 time: 9.87326
delta : 0.02458742 time: 9.856277
delta : 0.008400999 time: 9.83169
delta : 0.024809936 time: 9.823289
delta : 0.016923267 time: 9.798479
delta : 0.00830745 time: 9.781556
delta : 0.024903871 time: 9.773249
delta : 0.01678198 time: 9.748344
delta : 0.008349798 time: 9.731563
delta : 0.024851128 time: 9.723213
delta : 0.016850509 time: 9.698362
delta : 0.008247008 time: 9.681512
delta : 0.017021436 time: 9.6732645
delta : 0.016034737 time: 9.656243
delta : 0.016997185 time: 9.640208
delta : 0.016988328 time: 9.623211
delta : 0.01598546 time: 9.606222
delta : 0.016997954 time: 9.590237
delta : 0.017011428 time: 9.573238
delta : 0.015989695 time: 9.556227
delta : 0.017001418 time: 9.540237
delta : 0.017031832 time: 9.523236
delta : 0.024776058 time: 9.506205
delta : 0.016835492 time: 9.481428
delta : 0.008355572 time: 9.464593
delta : 0.024852283 time: 9.456238
delta : 0.017515363 time: 9.431385
delta : 0.007645287 time: 9.41387
delta : 0.024929663 time: 9.406224
delta : 0.008060679 time: 9.381294
delta : 0.025268447 time: 9.373234
delta : 0.016710375 time: 9.347965
delta : 0.008019101 time: 9.331255
delta : 0.017001804 time: 9.3232355
delta : 0.016020494 time: 9.306233
delta : 0.016995259 time: 9.290213
delta : 0.01699372 time: 9.273217
delta : 0.016036661 time: 9.256224
delta : 0.0169814 time: 9.240187
delta : 0.01699218 time: 9.223206
delta : 0.016001629 time: 9.206213
delta : 0.026093068 time: 9.190211
delta : 0.016605275 time: 9.164118
delta : 0.007309971 time: 9.147512
delta : 0.025673443 time: 9.1402025
delta : 0.008275882 time: 9.114529
delta : 0.025123691 time: 9.106253
delta : 0.007902068 time: 9.081129
delta : 0.017020281 time: 9.073227
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2014-07-10 22:14:36 »

Just what you would expect. Everything is perfectly fine.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline assjiggler

Senior Newbie





« Reply #10 - Posted 2014-07-10 22:20:30 »

Just what you would expect. Everything is perfectly fine.

i see that, but when the game is over it doesnt stop at one time, the 2nd decimal place flickers. rather then stop solidly at one number such as 4.51 and 4.52. or if it goes to zero it flickers from -0.00 to 0.00  . constantly flickers after game is over =/
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2014-07-10 22:23:16 »

Then print
time
and
String.format("time: %,.2f", time)
both to the console, after game-over, and dump the output here.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline assjiggler

Senior Newbie





« Reply #12 - Posted 2014-07-10 22:54:47 »

Then print
time
and
String.format("time: %,.2f", time)
both to the console, after game-over, and dump the output here.

i made the game go from 1 second to 0
althought the time says the right time it was rele flickering between .02 and .04
i was thinking maybe its placement of update texts  or time or what.

delta : 0.005415877 time: 0.99458414 onScreen time: 0.99
delta : 0.026823757 time: 0.9677604 onScreen time: 0.97
delta : 6.06341E-4 time: 0.967154 onScreen time: 0.97
delta : 0.017247804 time: 0.94990623 onScreen time: 0.95
delta : 0.016637228 time: 0.933269 onScreen time: 0.93
delta : 0.011882359 time: 0.92138666 onScreen time: 0.92
delta : 0.01652212 time: 0.90486455 onScreen time: 0.90
delta : 0.01786916 time: 0.8869954 onScreen time: 0.89
delta : 0.016226841 time: 0.87076855 onScreen time: 0.87
delta : 0.01592117 time: 0.8548474 onScreen time: 0.85
delta : 0.01597545 time: 0.8388719 onScreen time: 0.84
delta : 0.016988713 time: 0.8218832 onScreen time: 0.82
delta : 0.017014123 time: 0.80486906 onScreen time: 0.80
delta : 0.016010484 time: 0.7888586 onScreen time: 0.79
delta : 0.017039916 time: 0.7718187 onScreen time: 0.77
delta : 0.016983708 time: 0.754835 onScreen time: 0.75
delta : 0.015989695 time: 0.7388453 onScreen time: 0.74
delta : 0.017002959 time: 0.72184235 onScreen time: 0.72
delta : 0.016992947 time: 0.7048494 onScreen time: 0.70
delta : 0.016010098 time: 0.6888393 onScreen time: 0.69
delta : 0.016996028 time: 0.6718433 onScreen time: 0.67
delta : 0.017013352 time: 0.6548299 onScreen time: 0.65
delta : 0.015977375 time: 0.63885254 onScreen time: 0.64
delta : 0.017031062 time: 0.62182146 onScreen time: 0.62
delta : 0.016986404 time: 0.60483503 onScreen time: 0.60
delta : 0.01598623 time: 0.5888488 onScreen time: 0.59
delta : 0.017009504 time: 0.57183933 onScreen time: 0.57
delta : 0.017000264 time: 0.5548391 onScreen time: 0.55
delta : 0.016000474 time: 0.5388386 onScreen time: 0.54
delta : 0.016997568 time: 0.52184105 onScreen time: 0.52
delta : 0.016991409 time: 0.5048496 onScreen time: 0.50
delta : 0.016013563 time: 0.48883605 onScreen time: 0.49
delta : 0.017003344 time: 0.4718327 onScreen time: 0.47
delta : 0.017027596 time: 0.4548051 onScreen time: 0.45
delta : 0.015978532 time: 0.43882656 onScreen time: 0.44
delta : 0.016994871 time: 0.4218317 onScreen time: 0.42
delta : 0.017002573 time: 0.4048291 onScreen time: 0.40
delta : 0.015996238 time: 0.38883287 onScreen time: 0.39
delta : 0.01699526 time: 0.37183762 onScreen time: 0.37
delta : 0.017024903 time: 0.3548127 onScreen time: 0.35
delta : 0.01598854 time: 0.33882418 onScreen time: 0.34
delta : 0.016994871 time: 0.32182932 onScreen time: 0.32
delta : 0.016993335 time: 0.30483598 onScreen time: 0.30
delta : 0.016002014 time: 0.28883398 onScreen time: 0.29
delta : 0.016999878 time: 0.2718341 onScreen time: 0.27
delta : 0.01704184 time: 0.25479227 onScreen time: 0.25
delta : 0.015973525 time: 0.23881875 onScreen time: 0.24
delta : 0.016991794 time: 0.22182696 onScreen time: 0.22
delta : 0.0169968 time: 0.20483015 onScreen time: 0.20
delta : 0.016005864 time: 0.1888243 onScreen time: 0.19
delta : 0.017018355 time: 0.17180595 onScreen time: 0.17
delta : 0.017001804 time: 0.15480414 onScreen time: 0.15
delta : 0.016001629 time: 0.13880251 onScreen time: 0.14
delta : 0.01697062 time: 0.121831894 onScreen time: 0.12
delta : 0.017001035 time: 0.10483086 onScreen time: 0.10
delta : 0.016004324 time: 0.08882654 onScreen time: 0.09
delta : 0.016997952 time: 0.07182859 onScreen time: 0.07
delta : 0.016997185 time: 0.054831404 onScreen time: 0.05
delta : 0.016032428 time: 0.038798977 onScreen time: 0.04
delta : 0.016987175 time: 0.021811802 onScreen time: 0.02
delta : 0.017000264 time: 0.0048115384 onScreen time: 0.00
Offline assjiggler

Senior Newbie





« Reply #13 - Posted 2014-07-10 23:04:10 »

or maybe there is sumthing i can do with the placement of putting:
   Gdx.gl.glClearColor(0, 0 , 1, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

somewhere else or:
         stage.act(delta);
         stage.draw();

somewhere different
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2014-07-10 23:04:15 »

Maybe you simply stop rendering to the frames, not even clearing the frames.

The result is that you'll alternate between the last 2 frames that actually were rendered.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline assjiggler

Senior Newbie





« Reply #15 - Posted 2014-07-10 23:06:10 »

how would i go about doing that?
-thank you for your input by the way
Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #16 - Posted 2014-07-10 23:11:15 »

I know very little of LibGDX, and even less about your code - so I can't help you.
Make sure however, that you keep rendering to your frames - like keep rendering the current time (with System.currentTimeMillis()), and if you see the output alternating, you know you are not actually rendering anything, you just see the last 2 frames that were rendered into, being displayed.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline assjiggler

Senior Newbie





« Reply #17 - Posted 2014-07-10 23:17:26 »

i see.. sort of,  in libgdx   a show method is called first and never again, so that's where i do a lot of initializing. then the render method is just called over and over again. there is no way to stop the render method, with that being said i dont know how to just stop rendering one portion and not the rest. maybe create a new method =/
Offline assjiggler

Senior Newbie





« Reply #18 - Posted 2014-07-11 01:35:09 »

yeah still couldnt figure it out Sad this is rough man
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

pw (37 views)
2014-07-24 01:59:36

Riven (38 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00

Cero (60 views)
2014-07-16 00:42:17

Riven (57 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!