use of com.badlogic.gdx.scenes.scene2d.Action in project libgdx by libgdx.
the class AfterAction method delegate.
protected boolean delegate(float delta) {
Array<Action> currentActions = target.getActions();
if (currentActions.size == 1)
waitForActions.clear();
for (int i = waitForActions.size - 1; i >= 0; i--) {
Action action = waitForActions.get(i);
int index = currentActions.indexOf(action, true);
if (index == -1)
waitForActions.removeIndex(i);
}
if (waitForActions.size > 0)
return false;
return action.act(delta);
}
use of com.badlogic.gdx.scenes.scene2d.Action in project libgdx by libgdx.
the class ComplexActionTest method create.
@Override
public void create() {
stage = new Stage();
Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)), parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
final Image img1 = new Image(new TextureRegion(texture));
img1.setSize(100, 100);
img1.setOrigin(50, 50);
img1.setPosition(50, 50);
final Image img2 = new Image(new TextureRegion(texture));
img2.setSize(50, 50);
img2.setOrigin(50, 50);
img2.setPosition(150, 150);
stage.addActor(img1);
stage.addActor(img2);
img1.addAction(complexAction);
// img2.action(complexAction.copy());
}
use of com.badlogic.gdx.scenes.scene2d.Action in project libgdx by libgdx.
the class ParallelAction method act.
public boolean act(float delta) {
if (complete)
return true;
complete = true;
Pool pool = getPool();
// Ensure this action can't be returned to the pool while executing.
setPool(null);
try {
Array<Action> actions = this.actions;
for (int i = 0, n = actions.size; i < n && actor != null; i++) {
Action currentAction = actions.get(i);
if (currentAction.getActor() != null && !currentAction.act(delta))
complete = false;
// This action was removed.
if (actor == null)
return true;
}
return complete;
} finally {
setPool(pool);
}
}
Aggregations