@ -0,0 +1,36 @@
|
|||||||
|
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
|
import com.badlogic.gdx.utils.Pool;
|
||||||
|
import com.badlogic.gdx.utils.Pools;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/** Removes an actor from the stage.
|
||||||
|
* @author Nathan Sweet */
|
||||||
|
public class ChangeParentAction extends Action {
|
||||||
|
private final Pool<Vector2> vectorPool = Pools.get(Vector2.class);
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Group parent;
|
||||||
|
private boolean finished;
|
||||||
|
|
||||||
|
public boolean act (float delta) {
|
||||||
|
if (!finished) {
|
||||||
|
finished = true;
|
||||||
|
var pos = vectorPool.obtain();
|
||||||
|
pos.set(0, 0);
|
||||||
|
target.localToStageCoordinates(pos);
|
||||||
|
parent.stageToLocalCoordinates(pos);
|
||||||
|
target.setPosition(pos.x, pos.y);
|
||||||
|
parent.addActor(target);
|
||||||
|
vectorPool.free(pos);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restart () {
|
||||||
|
finished = false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||||
|
|
||||||
|
public class MyActions extends Actions {
|
||||||
|
public static ChangeParentAction changeParent(Group parent) {
|
||||||
|
var action = action(ChangeParentAction.class);
|
||||||
|
action.setParent(parent);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Action> T target(T action, Actor target) {
|
||||||
|
action.setTarget(target);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public SilentlyRemoveActorAction removeActorSilently () {
|
||||||
|
return action(SilentlyRemoveActorAction.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public SilentlyRemoveActorAction removeActorSilently(Actor removeActor) {
|
||||||
|
var action = action(SilentlyRemoveActorAction.class);
|
||||||
|
action.setTarget(removeActor);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||||
|
|
||||||
|
/** Removes an actor from the stage without immediately invalidating its parents. */
|
||||||
|
public class SilentlyRemoveActorAction extends Action {
|
||||||
|
private boolean removed;
|
||||||
|
|
||||||
|
public boolean act (float delta) {
|
||||||
|
if (!removed) {
|
||||||
|
removed = true;
|
||||||
|
if (target.getParent() != null) {
|
||||||
|
target.getParent().getChildren().removeValue(target, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restart () {
|
||||||
|
removed = false;
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 45 KiB |