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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.actions.SequenceAction. 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: RootTable.java    From skin-composer with MIT License 6 votes vote down vote up
public void refreshStyleProperties(boolean preserveScroll) {
    if (stylePropertiesTable != null && stylePropertiesScrollPane != null) {
        float scrollY;
        if (preserveScroll) {
            scrollY = stylePropertiesScrollPane.getScrollY();
        } else {
            scrollY = 0;
        }

        stylePropertiesTable.clearChildren();
        addStyleProperties(stylePropertiesTable);

        if (preserveScroll) {
            validate();
            stylePropertiesScrollPane.setSmoothScrolling(false);
            stylePropertiesScrollPane.setScrollY(scrollY);
            stylePropertiesScrollPane.addAction(new SequenceAction(new DelayAction(.1f), new Action() {
                @Override
                public boolean act(float delta) {
                    stylePropertiesScrollPane.setSmoothScrolling(true);
                    return true;
                }
            }));
        }
    }
}
 
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)));
}
 
Example #3
Source File: DefaultZoneView.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
@Override
public void zoomCard(final CardViewSmall cardView) {
	if (this.cardZoomedIn) {
		return;
	}
	final CardViewSmall cardViewCopy = new CardViewSmall(this.context, cardView.cardInfo, this, true);
	cardViewCopy.getActor().setPosition(Gdx.graphics.getWidth()/2.7f, Gdx.graphics.getHeight()/30);
	this.context.getStage().addActor(cardViewCopy.getActor());
	this.initialCardViewWidth = cardView.getActor().getWidth();
	this.initialCardViewHeight = cardView.getActor().getHeight();
	SequenceAction sequence = new SequenceAction();
	Runnable adjustForZoom = new Runnable() {
	    @Override
	    public void run() {
	    	cardViewCopy.zoom();
	    }
	};
	sequence.addAction(Actions.sizeTo(Gdx.graphics.getWidth()/4, Gdx.graphics.getHeight()*0.9f, 0.2f));
	sequence.addAction(Actions.run(adjustForZoom));		
	cardViewCopy.getActor().addAction(sequence);
	this.cardZoomedIn = true;
}
 
Example #4
Source File: DeckBuilderScreen.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
@Override
public void zoomCard(final CardViewSmall cardView) {
	if (this.cardZoomedIn) {
		return;
	}
	final CardViewSmall cardViewCopy = new CardViewSmall(this.context, cardView.cardInfo, this, true);
	cardViewCopy.setTargetable(TargetStatus.TARGETABLE, this);
	cardViewCopy.getActor().setPosition(this.screenWidth/2.7f, this.screenHeight/30);
	this.game.stage.addActor(cardViewCopy.getActor());
	this.initialCardViewWidth = cardView.getActor().getWidth();
	this.initialCardViewHeight = cardView.getActor().getHeight();
	SequenceAction sequence = new SequenceAction();
	Runnable adjustForZoom = new Runnable() {
	    @Override
	    public void run() {
	    	cardViewCopy.zoom();
	    }
	};
	sequence.addAction(Actions.sizeTo(this.screenWidth/4, this.screenHeight*0.9f, 0.2f));
	sequence.addAction(Actions.run(adjustForZoom));		
	cardViewCopy.getActor().addAction(sequence);
	this.cardZoomedIn = true;
}
 
Example #5
Source File: Entity.java    From Norii with Apache License 2.0 5 votes vote down vote up
public void moveAttack(List<GridCell> path, Entity target) {
	final SequenceAction sequence = createMoveSequence(path);
	sequence.addAction(new AttackAction(target));
	sequence.addAction(run(aiFinishTurn));

	this.getEntityactor().addAction(sequence);
	this.setAp(this.getAp() - path.size() - this.getEntityData().getBasicAttackCost());
}
 
Example #6
Source File: Entity.java    From Norii with Apache License 2.0 5 votes vote down vote up
private SequenceAction createMoveSequence(List<GridCell> path) {
	GridCell oldCell = new GridCell(this.getCurrentPosition().getTileX(), this.getCurrentPosition().getTileY());
	final SequenceAction sequence = Actions.sequence();
	for (final GridCell cell : path) {
		sequence.addAction(Actions.rotateTo(decideRotation(oldCell, cell), 0.1f));
		sequence.addAction(moveTo(cell.x, cell.y, 0.2f));
		sequence.addAction(run(updatePositionAction));
		oldCell = cell;
	}
	return sequence;
}
 
Example #7
Source File: DialogLoading.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    RunnableAction runnableAction = new RunnableAction();
    runnableAction.setRunnable(() -> {
        if (Utils.isMac()) {
            if (runnable != null) {
                runnable.run();
            }
            hide();
        } else {
            Thread thread = new Thread(() -> {
                if (runnable != null) {
                    runnable.run();
                }
                Gdx.app.postRunnable(() -> {
                    hide();
                });
            });
            thread.start();
        }
    });
    Action action = new SequenceAction(new DelayAction(.5f), runnableAction);
    addAction(action);
    
    return dialog;
}
 
Example #8
Source File: MenuList.java    From skin-composer with MIT License 5 votes vote down vote up
public void hide() {
    //fade out and then remove
    clearActions();
    AlphaAction alphaAction = new AlphaAction();
    alphaAction.setAlpha(0.0f);
    alphaAction.setDuration(.3f);
    alphaAction.setInterpolation(Interpolation.fade);
    RemoveActorAction removeAction = new RemoveActorAction();
    removeAction.setActor(this);
    SequenceAction sequenceAction = new SequenceAction(alphaAction, removeAction);
    addAction(sequenceAction);
}
 
Example #9
Source File: Tutorial.java    From martianrun with Apache License 2.0 5 votes vote down vote up
public Tutorial(Rectangle bounds, String assetsId, String text) {
    this.bounds = bounds;
    this.text = text;
    textureRegion = AssetsManager.getTextureRegion(assetsId);
    SequenceAction sequenceAction = new SequenceAction();
    sequenceAction.addAction(Actions.delay(4f));
    sequenceAction.addAction(Actions.removeActor());
    addAction(sequenceAction);
    font = AssetsManager.getSmallestFont();
    setWidth(bounds.width);
    setHeight(bounds.height);
}
 
Example #10
Source File: Entity.java    From Norii with Apache License 2.0 4 votes vote down vote up
public void move(List<GridCell> path) {
	final SequenceAction sequence = createMoveSequence(path);
	sequence.addAction(run(aiFinishTurn));
	this.getEntityactor().addAction(sequence);
	this.setAp(this.getAp() - path.size());
}