static public MoveToAction moveToAligned (float x, float y, int alignment) { return moveToAligned(x, y, alignment, 0, null); }
static public MoveToAction moveToAligned (float x, float y, int alignment, float duration) { return moveToAligned(x, y, alignment, duration, null); }
static public MoveToAction moveToAligned (float x, float y, int alignment, float duration) { return moveToAligned(x, y, alignment, duration, null); }
static public MoveToAction moveToAligned (float x, float y, int alignment) { return moveToAligned(x, y, alignment, 0, null); }
static public MoveToAction moveToAligned (float x, float y, int alignment) { return moveToAligned(x, y, alignment, 0, null); }
static public MoveToAction moveToAligned (float x, float y, int alignment, float duration) { return moveToAligned(x, y, alignment, duration, null); }
if (0 < delay) sequence[index++] = Actions.delay(delay); sequence[index++] = Actions.moveToAligned(x + direction.deltaX * 0.35f * font.actualCellWidth, y - direction.deltaY * 0.35f * font.actualCellHeight, Align.bottomLeft, duration * 0.35F); sequence[index++] = Actions.moveToAligned(x, y, Align.bottomLeft, duration * 0.65F); if(postRunnable != null)
sequence[index++] = Actions.delay(delay); final StatefulRNG gRandom = DefaultResources.getGuiRandom(); sequence[index++] = Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F); sequence[index++] = Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F); sequence[index++] = Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F); sequence[index++] = Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F); sequence[index++] = Actions.moveToAligned(x, y, Align.bottomLeft, duration * 0.2F); if(postRunnable != null)
/** * Start a bumping animation in the given direction that will last duration seconds. * @param ae an AnimatedEntity returned by animateActor() * @param direction * @param duration a float, measured in seconds, for how long the animation should last; commonly 0.12f */ public void bump(final AnimatedEntity ae, Direction direction, float duration) { final Actor a = ae.actor; final float x = adjustX(ae.gridX, ae.doubleWidth), y = adjustY(ae.gridY); if(a == null || ae.animating) return; duration = clampDuration(duration); animationCount++; ae.animating = true; a.addAction(Actions.sequence( Actions.moveToAligned(x + direction.deltaX * cellWidth * 0.35f, y - direction.deltaY * cellHeight * 0.35f, Align.bottomLeft, duration * 0.35F), Actions.moveToAligned(x, y, Align.bottomLeft, duration * 0.65F), Actions.delay(duration, Actions.run(new Runnable() { @Override public void run() { recallActor(ae, ae.gridX, ae.gridY); } })))); } /**
StatefulRNG gRandom = DefaultResources.getGuiRandom(); a.addAction(Actions.sequence( Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(x + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, y + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(x, y, Align.bottomLeft, duration * 0.2F), Actions.delay(duration, Actions.run(new Runnable() { @Override
Actions.moveToAligned(nextX + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, nextY + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(nextX + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, nextY + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(nextX + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, nextY + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(nextX + (gRandom.nextFloat() - 0.5F) * cellWidth * 0.4f, nextY + (gRandom.nextFloat() - 0.5F) * cellHeight * 0.4f, Align.bottomLeft, duration * 0.2F), Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration * 0.2F), Actions.delay(duration, Actions.run(new Runnable() { @Override
Actions.moveToAligned(nextX + direction.deltaX * cellWidth * 0.35f, nextY + direction.deltaY * cellHeight * 0.35f, Align.bottomLeft, duration * 0.35F), Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration * 0.65F), Actions.delay(duration, Actions.run(new Runnable() { @Override
final float nextX = adjustX(newX, false); final float nextY = adjustY(newY); sequence[index++] = Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration); if(postRunnable != null)
/** * Start a movement animation for the object at the grid location x, y and moves it to newX, newY over a number of * seconds given by duration (often 0.12f or somewhere around there). * @param ae an AnimatedEntity returned by animateActor() * @param newX * @param newY * @param duration */ public void slide(final AnimatedEntity ae, final int newX, final int newY, float duration) { final Actor a = ae.actor; final float nextX = adjustX(newX, ae.doubleWidth), nextY = adjustY(newY); if(a == null || ae.animating) return; duration = clampDuration(duration); animationCount++; ae.animating = true; ae.gridX = newX; ae.gridY = newY; a.addAction(Actions.sequence( Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration), Actions.delay(duration, Actions.run(new Runnable() { @Override public void run() { recallActor(ae, newX, newY); } })))); }
final float nextX = worldX(newX); final float nextY = worldY(newY); sequence[index++] = Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration); if(postRunnable != null)
Actions.moveToAligned(nextX, nextY, Align.bottomLeft, duration), Actions.delay(duration, Actions.run(new Runnable() { @Override