com.badlogic.gdx.scenes.scene2d.actions.ParallelAction Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.actions.ParallelAction. 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: CustomTargetAction.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
private void recursivelyUpdateTarget(Action action, Actor target) {
    if (action instanceof CustomTargetAction) return;

    action.setTarget(target);

    if (action instanceof DelegateAction) {
        DelegateAction delegateAction = (DelegateAction) action;
        Action wrappedAction = delegateAction.getAction();
        if (!(wrappedAction instanceof CustomTargetAction)) {
            recursivelyUpdateTarget(wrappedAction, target);
        }

    } else if (action instanceof ParallelAction) {
        ParallelAction parallelAction = (ParallelAction) action;
        Array<Action> actions = parallelAction.getActions();
        for (int i = 0; i < actions.size; i++) {
            Action childAction = actions.get(i);
            if (!(childAction instanceof CustomTargetAction)) {
                recursivelyUpdateTarget(childAction, target);
            }
        }
    }
}
 
Example #2
Source File: CCSpriteViewTest.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@Test
@NeedGL
public void shouldParseSpriteView() throws Exception {
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("animation/MainScene.json"), null, null, null, null);

    Group group = editor.createGroup();
    Image image = group.findActor("st_2");
    Array<Action> actions = image.getActions();
    assertThat(actions.size, is(1));
    RepeatAction repeatAction = (RepeatAction) actions.get(0);
    ParallelAction parallelAction = (ParallelAction) repeatAction.getAction();
    assertThat(parallelAction.getActions().size, is(3));
    assertThat(parallelAction.getActions(), (Matcher) everyItem(instanceOf(SequenceAction.class)));
    SequenceAction moveAction = (SequenceAction) parallelAction.getActions().get(0);
    SequenceAction scaleAction = (SequenceAction) parallelAction.getActions().get(1);
    assertThat(moveAction.getActions().size, is(4));
    assertThat(moveAction.getActions(), (Matcher) everyItem(instanceOf(MoveToAction.class)));
    assertThat(scaleAction.getActions().size, is(4));
    assertThat(scaleAction.getActions(), (Matcher) everyItem(instanceOf(ScaleToAction.class)));
}