Search in sources :

Example 1 with Pool

use of com.badlogic.gdx.utils.Pool in project libgdx by libgdx.

the class DelegateAction method act.

public final boolean act(float delta) {
    Pool pool = getPool();
    // Ensure this action can't be returned to the pool inside the delegate action.
    setPool(null);
    try {
        return delegate(delta);
    } finally {
        setPool(pool);
    }
}
Also used : Pool(com.badlogic.gdx.utils.Pool)

Example 2 with Pool

use of com.badlogic.gdx.utils.Pool 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);
    }
}
Also used : Action(com.badlogic.gdx.scenes.scene2d.Action) Pool(com.badlogic.gdx.utils.Pool)

Example 3 with Pool

use of com.badlogic.gdx.utils.Pool in project libgdx by libgdx.

the class RunnableAction method run.

/** Called to run the runnable. */
public void run() {
    Pool pool = getPool();
    // Ensure this action can't be returned to the pool inside the runnable.
    setPool(null);
    try {
        runnable.run();
    } finally {
        setPool(pool);
    }
}
Also used : Pool(com.badlogic.gdx.utils.Pool)

Example 4 with Pool

use of com.badlogic.gdx.utils.Pool in project libgdx by libgdx.

the class SequenceAction method act.

public boolean act(float delta) {
    if (index >= actions.size)
        return true;
    Pool pool = getPool();
    // Ensure this action can't be returned to the pool while executings.
    setPool(null);
    try {
        if (actions.get(index).act(delta)) {
            // This action was removed.
            if (actor == null)
                return true;
            index++;
            if (index >= actions.size)
                return true;
        }
        return false;
    } finally {
        setPool(pool);
    }
}
Also used : Pool(com.badlogic.gdx.utils.Pool)

Example 5 with Pool

use of com.badlogic.gdx.utils.Pool in project libgdx by libgdx.

the class TemporalAction method act.

public boolean act(float delta) {
    if (complete)
        return true;
    Pool pool = getPool();
    // Ensure this action can't be returned to the pool while executing.
    setPool(null);
    try {
        if (!began) {
            begin();
            began = true;
        }
        time += delta;
        complete = time >= duration;
        float percent;
        if (complete)
            percent = 1;
        else {
            percent = time / duration;
            if (interpolation != null)
                percent = interpolation.apply(percent);
        }
        update(reverse ? 1 - percent : percent);
        if (complete)
            end();
        return complete;
    } finally {
        setPool(pool);
    }
}
Also used : Pool(com.badlogic.gdx.utils.Pool)

Aggregations

Pool (com.badlogic.gdx.utils.Pool)5 Action (com.badlogic.gdx.scenes.scene2d.Action)1