Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

Timer.schedule(task, 0, 100) never fires

$
0
0

I added some code using java.util.Timer to execute my spawnMonster function every 100ms. It worked, until I tried instantiating images in it — since it doesn’t run on the libGDX core thread, there’s no OpenGL context, so it can’t do stuff with images.

I figured using the libGDX Timer class, which the javadocs say runs on the core thread, would solve this problem; but unfortunately, the timer code just doesn’t execute.

I tried:


- new Timer().scheduleTask(task, 0, 100)
- new Timer().scheduleTask(task, 0, 100, 99999)
- Timer.schedule(task, 0, 100)
- Timer.schedule(task, 0, 999999)
- Timer.start()
- t = new Timer(); t.scheduleTask(...); t.start();

task appears to execute once, and only once; it never executes again. (It prints a date-time diff from a target time, so I can tell it’s not running.)


Viewing all articles
Browse latest Browse all 434

Trending Articles