protected boolean delegate (float delta) { if (action == null) return true; return action.act(delta * scale); }
public void reset () { super.reset(); reverse = false; interpolation = null; }
/** Resets the optional state of this action to as if it were newly created, allowing the action to be pooled and reused. State * required to be set for every usage of this action or computed during the action does not need to be reset. * <p> * The default implementation calls {@link #restart()}. * <p> * If a subclass has optional state, it must override this method, call super, and reset the optional state. */ public void reset () { actor = null; target = null; pool = null; restart(); }
public boolean act (float delta) { if (complete) return true; complete = true; Pool pool = getPool(); setPool(null); // Ensure this action can't be returned to the pool while executing. 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; if (actor == null) return true; // This action was removed. } return complete; } finally { setPool(pool); } }
/** Updates the actor based on time. Typically this is called each frame by {@link Stage#act(float)}. * <p> * The default implementation calls {@link Action#act(float)} on each action and removes actions that are complete. * @param delta Time in seconds since the last frame. */ public void act (float delta) { Array<Action> actions = this.actions; if (actions.size == 0) return; if (stage != null && stage.getActionsRequestRendering()) Gdx.graphics.requestRendering(); try { for (int i = 0; i < actions.size; i++) { Action action = actions.get(i); if (action.act(delta) && i < actions.size) { Action current = actions.get(i); int actionIndex = current == action ? i : actions.indexOf(action, true); if (actionIndex != -1) { actions.removeIndex(actionIndex); action.setActor(null); i--; } } } } catch (RuntimeException ex) { String context = toString(); throw new RuntimeException("Actor: " + context.substring(0, Math.min(context.length(), 128)), ex); } }
public String toString () { return super.toString() + (action == null ? "" : "(" + action + ")"); } }
/** Returns a new or pooled action of the specified type. */ static public <T extends Action> T action (Class<T> type) { Pool<T> pool = Pools.get(type); T action = pool.obtain(); action.setPool(pool); return action; }
public void restart () { if (action != null) action.restart(); }
public boolean act (float delta) { if (complete) return true; complete = true; Pool pool = getPool(); setPool(null); // Ensure this action can't be returned to the pool while executing. 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; if (actor == null) return true; // This action was removed. } return complete; } finally { setPool(pool); } }
/** Updates the actor based on time. Typically this is called each frame by {@link Stage#act(float)}. * <p> * The default implementation calls {@link Action#act(float)} on each action and removes actions that are complete. * @param delta Time in seconds since the last frame. */ public void act (float delta) { Array<Action> actions = this.actions; if (actions.size == 0) return; if (stage != null && stage.getActionsRequestRendering()) Gdx.graphics.requestRendering(); try { for (int i = 0; i < actions.size; i++) { Action action = actions.get(i); if (action.act(delta) && i < actions.size) { Action current = actions.get(i); int actionIndex = current == action ? i : actions.indexOf(action, true); if (actionIndex != -1) { actions.removeIndex(actionIndex); action.setActor(null); i--; } } } } catch (RuntimeException ex) { String context = toString(); throw new RuntimeException("Actor: " + context.substring(0, Math.min(context.length(), 128)), ex); } }
public String toString () { return super.toString() + (action == null ? "" : "(" + action + ")"); } }
/** Returns a new or pooled action of the specified type. */ static public <T extends Action> T action (Class<T> type) { Pool<T> pool = Pools.get(type); T action = pool.obtain(); action.setPool(pool); return action; }
public void reset () { super.reset(); action = null; } }
protected boolean delegate (float delta) { if (time < duration) { time += delta; if (time < duration) return false; delta = time - duration; } if (action == null) return true; return action.act(delta); }