本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.actions.MoveByAction类的典型用法代码示例。如果您正苦于以下问题:Java MoveByAction类的具体用法?Java MoveByAction怎么用?Java MoveByAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoveByAction类属于com.badlogic.gdx.scenes.scene2d.actions包,在下文中一共展示了MoveByAction类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: move
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
public void move(int x, int y) {
float size = 32.0f;
// Distance in pixels
float dx = size * x;
float dy = size * y;
int destX = getPosX() + x;
int destY = getPosY() + y;
MoveByAction moveX = new MoveByAction();
moveX.setAmountX(dx);
moveX.setDuration(Math.abs(x) * 0.1f);
MoveByAction moveY = new MoveByAction();
moveY.setAmountY(dy);
moveY.setDuration(Math.abs(y) * 0.1f);
moveSeq = new SequenceAction(moveX, moveY);
Speech.getInstance().speak("move " + this.name + " to " + getLetter(destY) + " " + (destX + 1));
this.setPosition(destY, destX);
this.addAction(moveSeq);
moved = true;
GameState.getInstance().addMove();
}
示例2: actionMoveBy
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
/**
* Action move by.
*
* @param x the x
* @param y the y
* @param duration the duration
*/
public void actionMoveBy(float x, float y, float duration) {
// Move towards a direction during given time (NON-STOP)
MoveByAction action = new MoveByAction();
action.setAmount(x, y);
if (duration > 0) {
action.setDuration(duration);
}
addAction(action);
}
示例3: isPlayerMoving
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
/**
* Prüft, ob der übergebene Player sich bewegt anhand des Vorhandenseins
* einer MoveByAction.
*
* @param player
* Der Spieler
* @return true wenn der Player sich bewegt, sonst false
*/
protected static boolean isPlayerMoving(final Player player) {
Array<Action> actions = player.getActions();
for (Action action : actions) {
if (action instanceof MoveByAction) {
return true;
}
}
return false;
}
示例4: movePlayer
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
/**
* Bewegt den Player von seiner aktuellen Position in einer flüssigen
* Animation auf geradem Weg zur einer anderen Stadt.
*
* @param city
* Die Ziel Stadt.
*/
private void movePlayer(final String city) {
int[] cityCoordinates = cityInfos.get(city);
Vector2 source = new Vector2(player.getX() + player.getWidth() / 2
* player.getScaleX(), player.getY());
Vector2 target = new Vector2(cityCoordinates[0], cityCoordinates[1]);
Direction animationDirection = WorldMapUtils.getDirection(source,
target);
AnimationAction animationRun = new AnimationAction(animationDirection,
PLAYERSPEED);
// Weggelassen, da alleine schon die Existens einer Idle AnimationAction
// während der Abarbeitung einer anderen AnimationAction
// stand 14.12.14 zum Fehler führt
// AnimationAction animationIdle = new
// AnimationAction(WorldMapUtils.getIdleDirection(animationDirection));
// SequenceAction animationSequence = new SequenceAction(animationRun,
// animationIdle);
MoveByAction movement = new MoveByAction();
movement.setAmount(target.x - source.x, target.y - source.y);
movement.setDuration(PLAYERSPEED);
player.clearActions();
player.setAnimationSpeed(1 - PLAYERSPEED / 2.5f);
player.addAction(movement);
// player.addAction(animationSequence);
player.addAction(animationRun);
}
示例5: Pipe
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
public Pipe(TextureRegion region, Stage stage, Droid droid, boolean countPipe, OnScoreListener listener) {
super(region);
mAndy = droid;
mStage = stage;
mCountPipe = countPipe;
mListener = listener;
MoveByAction moveLeft = new MoveByAction();
moveLeft.setDuration(FlopsyScreen.SPEED);
moveLeft.setAmountX(-Ground.GROUND_WIDTH);
addAction(Actions.forever(moveLeft));
}
示例6: playDeathAnimation
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
public void playDeathAnimation() {
float x = 50;
if(playerActor.getDirection()) {
x = -x;
}
MoveByAction moveUp = Actions.moveBy(x, 0, 0.1f + 0.002f*playerActor.getY());
moveUp.setInterpolation(Interpolation.circleOut);
MoveByAction moveDown = Actions.moveBy(0,-(playerActor.getY() + playerActor.getWidth()), 0.1f+0.002f*playerActor.getY());
moveDown.setInterpolation(Interpolation.swingIn);
Action deathAction = Actions.parallel(moveUp,moveDown);
playerActor.addAction(deathAction);
}
示例7: move
import com.badlogic.gdx.scenes.scene2d.actions.MoveByAction; //导入依赖的package包/类
private static MoveByAction move(Actor actor, float targetX, float targetY) {
return Actions.moveBy(targetX - actor.getX(), targetY - actor.getY(),
HIDE_TIME, Interpolation.exp5Out);
}