} catch (Exception ex) {\r
Display.destroy();\r
try {\r
+ Thread.sleep(200);\r
+ } catch (InterruptedException ignored) {\r
+ }\r
+ try {\r
Display.create(new PixelFormat(0, 16, 8));\r
if (getDesktopDisplayMode().bitsPerPixel == 16) {\r
bufferFormat = new BufferFormat(5, 6, 5, 0, 16, 8, 0, false);\r
} catch (Exception ex2) {\r
Display.destroy();\r
try {\r
+ Thread.sleep(200);\r
+ } catch (InterruptedException ignored) {\r
+ }\r
+ try {\r
Display.create(new PixelFormat());\r
} catch (Exception ex3) {\r
if (ex3.getMessage().contains("Pixel format not accelerated"))\r
* the methods here do nothing with the event. Users are expected to override the methods they are interested in, like this:\r
* \r
* <pre>\r
- * {@code\r
* actor.addListener(new InputListener() {\r
* public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {\r
* Gdx.app.log("Example", "touch started at (" +x+ ", " +y+ ")");\r
* Gdx.app.log("Example", "touch done at (" +x+ ", " +y+ ")");\r
* }\r
* });\r
- * }\r
* </pre>\r
*/\r
public class InputListener implements EventListener {\r
\r
/** Sets the slider position, rounded to the nearest step size and clamped to the minumum and maximim values. */\r
public void setValue (float value) {\r
- if (value < min || value > max) throw new IllegalArgumentException("value must be >= min and <= max: " + value);\r
value = MathUtils.clamp(Math.round(value / stepSize) * stepSize, min, max);\r
float oldValue = this.value;\r
if (value == oldValue) return;\r
synchronized (instances) {\r
float time = System.nanoTime() * MathUtils.nanoToSec;\r
float wait = Float.MAX_VALUE;\r
- for (int i = 0, n = instances.size; i < n; i++)\r
- wait = Math.min(wait, instances.get(i).update(time));\r
+ for (int i = 0, n = instances.size; i < n; i++) {\r
+ try {\r
+ wait = instances.get(i).update(time, wait);\r
+ } catch (Throwable ex) {\r
+ throw new GdxRuntimeException("Task failed: " + instances.get(i).getClass().getName(), ex);\r
+ }\r
+ }\r
long waitMillis = (long)(wait * 1000);\r
try {\r
if (waitMillis > 0) instances.wait(waitMillis);\r
task.executeTime = System.nanoTime() * MathUtils.nanoToSec + delaySeconds;\r
task.intervalSeconds = intervalSeconds;\r
task.repeatCount = repeatCount;\r
- synchronized(tasks) {\r
+ synchronized (tasks) {\r
tasks.add(task);\r
}\r
wake();\r
\r
/** Cancels all tasks. */\r
public void clear () {\r
- synchronized(tasks) {\r
+ synchronized (tasks) {\r
for (int i = 0, n = tasks.size; i < n; i++)\r
tasks.get(i).cancel();\r
tasks.clear();\r
}\r
}\r
\r
- float update (float time) {\r
- float wait = Float.MAX_VALUE;\r
- synchronized(tasks) {\r
+ float update (float time, float wait) {\r
+ synchronized (tasks) {\r
for (int i = 0, n = tasks.size; i < n; i++) {\r
Task task = tasks.get(i);\r
if (task.executeTime > time) {\r
continue;\r
}\r
if (task.repeatCount != CANCELLED) {\r
- if (task.repeatCount == 0) task.repeatCount = CANCELLED; // Set cancelled before run so it may be rescheduled in run.\r
+ if (task.repeatCount == 0) {\r
+ // Set cancelled before run so it may be rescheduled in run.\r
+ task.repeatCount = CANCELLED;\r
+ }\r
Gdx.app.postRunnable(task);\r
}\r
if (task.repeatCount == CANCELLED) {\r