Java Code Examples for com.badlogic.gdx.utils.Timer#post()

The following examples show how to use com.badlogic.gdx.utils.Timer#post() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FutureListenerPromise.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
/**
 * @see FuturePromise#when(Consumer)
 */
@SuppressWarnings("unchecked")
public static <R> FutureListenerPromise<R> whenListener(final Consumer<FutureListenerPromise<R>> consumer) {
    final FutureListenerPromise<R> promise = new FutureListenerPromise<>();
    promise.execution = new Runnable() {
        @Override
        public void run() {
            promise.execution = null;
            try {
                consumer.accept(promise);
            } catch (Exception e) {
                promise.stackRecognizer.getBottomThenPromise().doFail(e);
            }
        }
    };
    if (GdxFIRApp.isAutoSubscribePromises()) {
        promise.subscribeTask = Timer.post(new AutoSubscribeTask(promise));
    }
    return promise;
}
 
Example 2
Source File: ConverterPromise.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
/**
 * @see FuturePromise#when(Consumer)
 */
@SuppressWarnings("unchecked")
public static <T, R> ConverterPromise<T, R> whenWithConvert(final Consumer<ConverterPromise<T, R>> consumer) {
    final ConverterPromise<T, R> promise = new ConverterPromise<>();
    promise.execution = new Runnable() {
        @Override
        public void run() {
            promise.execution = null;
            try {
                consumer.accept(promise);
            } catch (Exception e) {
                promise.stackRecognizer.getBottomThenPromise().doFail(e);
            }
        }
    };
    if (GdxFIRApp.isAutoSubscribePromises()) {
        promise.subscribeTask = Timer.post(new AutoSubscribeTask(promise));
    }
    return promise;
}
 
Example 3
Source File: FuturePromise.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
public static synchronized <R> FuturePromise<R> when(final Consumer<FuturePromise<R>> consumer) {
    final FuturePromise<R> promise = new FuturePromise<>();
    promise.execution = new Runnable() {
        @Override
        public void run() {
            promise.execution = null;
            try {
                consumer.accept(promise);
            } catch (Exception e) {
                promise.stackRecognizer.getBottomThenPromise().doFail(e);
            }
        }
    };
    if (GdxFIRApp.isAutoSubscribePromises()) {
        promise.subscribeTask = Timer.post(new AutoSubscribeTask(promise));
    }
    return promise;
}
 
Example 4
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
public static void showMsg(final Stage stage, final String text, final boolean modal) {

	// show in the next frame to allow calling when no OpenGL context is available.
	Timer.post(new Task() {

		@Override
		public void run() {
			isModal = modal;

			if (text == null) {
				hideMsg();
				return;
			}

			add(stage, text);

			if (FADE_DURATION > 0) {
				msg.getColor().a = 0;
				msg.addAction(Actions.fadeIn(FADE_DURATION, Interpolation.fade));
			}

		}
	});

}
 
Example 5
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
public static void showMsg(final Stage stage, final String text, final float duration) {

	Timer.post(new Task() {

		@Override
		public void run() {
			isModal = false;

			if (text == null) {
				hideMsg();
				return;
			}

			add(stage, text);

			if (FADE_DURATION > 0) {
				msg.getColor().a = 0;
				msg.addAction(sequence(Actions.fadeIn(FADE_DURATION, Interpolation.fade), Actions.delay(duration,
						sequence(fadeOut(FADE_DURATION, Interpolation.fade), Actions.removeActor()))));
			} else {
				msg.addAction(sequence(Actions.delay(duration, Actions.removeActor())));
			}
		}
	});

}
 
Example 6
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public static void showMsgDialog(final Stage stage, final String title, final String msg) {

		Timer.post(new Task() {

			@Override
			public void run() {
				Message.hideMsg();
				
				new Dialog(title, skin).text(msg).button("Close", true).key(Keys.ENTER, true).key(Keys.ESCAPE, false)
						.show(stage);
			}
		});
	}