本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.actions.Actions类的典型用法代码示例。如果您正苦于以下问题:Java Actions类的具体用法?Java Actions怎么用?Java Actions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Actions类属于com.badlogic.gdx.scenes.scene2d.actions包,在下文中一共展示了Actions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override
public void create () {
camera = new OrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
stage = new Stage();
stage.addListener(new InputListener(){
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){
stage.getActors().get(counter).addAction(Actions.moveTo(x-50,y-50,1));
counter++;
if(counter==stage.getActors().size) {
counter=0;
}
return true;
}
});
Gdx.input.setInputProcessor(stage);
}
示例2: displayScores
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override
public void displayScores(List<PlayerData> data) {
table.clear();
table.row();
Label winner = new Label("Last penguin standing: " + data.get(0).displayName, uiSkin);
table.add(winner).pad(10);
for (int i = 0; i < data.size(); i++) {
int rank = i + 1;
PlayerData player = data.get(i);
table.row();
String newBest = getBestText(player);
Label l = new Label(rank + ". " + player.displayName + " " + data.get(i).totalScore + newBest, uiSkin);
table.add(l).pad(5);
}
table.row();
table.add(menuButton).pad(30);
menuButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
controller.onBack();
}
});
table.addAction(Actions.fadeIn(1));
}
示例3: hide
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void hide() {
shown = false;
hiding = true;
Gdx.input.setInputProcessor(lastInputProcessor);
addAction(Actions.sequence(
Actions.moveTo(0, Gdx.graphics.getHeight(), 0.5f, Interpolation.swingIn),
new RunnableAction() {
@Override
public void run() {
hiding = false;
}
}
));
scorer.resume();
}
示例4: setUpSkinImages
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
public void setUpSkinImages() {
skinImage = new Image(skins.get(position).getTextureRegion());
skinImageRotation = new Image(skins.get(position).getTextureRegion());
skinImage.setSize(3f, 3f);
skinImage.setOrigin(skinImage.getWidth() / 2, skinImage.getHeight() / 2);
skinImage.setPosition(Constants.WIDTH / 3 - skinImage.getWidth() / 2, Constants.HEIGHT / 2);
skinImageRotation.setSize(3f, 3f);
skinImageRotation.setOrigin(skinImageRotation.getWidth() / 2, skinImageRotation.getHeight() / 2);
skinImageRotation.setPosition(Constants.WIDTH * 2 / 3 - skinImageRotation.getWidth() / 2, Constants.HEIGHT / 2);
SequenceAction rotateAction = new SequenceAction();
rotateAction.addAction(Actions.rotateBy(360, 0.5f, Interpolation.linear));
RepeatAction infiniteLoop = new RepeatAction();
infiniteLoop.setCount(RepeatAction.FOREVER);
infiniteLoop.setAction(rotateAction);
skinImageRotation.addAction(infiniteLoop);
stage.addActor(skinImageRotation);
stage.addActor(skinImage);
}
示例5: reactOnClick
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
public void reactOnClick() {
//Action testAction = Actions.moveBy(10, 15);//sizeBy, moveBy and other action :D
int xMoveAmount = MathUtils.random(-130, 130);
Action moveAction = Actions.sequence(
Actions.moveBy(xMoveAmount, 10, 0.30f, Interpolation.circleOut),
Actions.moveBy(-xMoveAmount, -10, 0.30f, Interpolation.circle)
);
int yGrowAmount = MathUtils.random(-30, 100);
Action growAction = Actions.sequence(
Actions.sizeBy(yGrowAmount, 20, 0.2f, Interpolation.circleOut),
Actions.sizeBy(-yGrowAmount, -20, 0.2f, Interpolation.circle)
);
this.addAction(moveAction);
this.addAction(growAction);
if(this.getHeight() > 170) {
this.addAction(Actions.rotateBy(MathUtils.randomSign() * 360, 0.4f));
}
}
示例6: showLevelComplete
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void showLevelComplete() {
levelCompleteBackground.setVisible(true);
nextButton.getColor().a = 0;
nextButton.addAction(Actions.alpha(1, 1.5f));
nextButton.setVisible(true);
long duration = DAO.getInstance().getLong(DAO.TOTAL_TIME_KEY, 0);
levelSummaryLabel.setText("TIME TAKEN: " + getTimeTakenDisplay(duration));
levelSummaryLabel.setVisible(true);
if (!Globals.isDesktop() && moveButton != null && jumpButton != null) {
moveButton.setDisabled(true);
moveButton.setVisible(false);
jumpButton.setDisabled(true);
jumpButton.setVisible(false);
}
}
示例7: tweenToHidden
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void tweenToHidden(float duration, Runnable callback) {
Table menuTable = menuBar.getTable();
/*
menuBar.getTable().setPosition(0, Gdx.graphics.getHeight()+menuBar.getTable().getHeight());
menuBar.getTable().getColor().a = 0;
*/
menuTable.addAction(Actions.sequence(
Actions.parallel(
Actions.moveTo(0, Gdx.graphics.getHeight()+menuBar.getTable().getHeight(), duration),
Actions.fadeOut(duration)
), Actions.run(() ->{
if(callback != null) callback.run();
})
));
}
示例8: backClick
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void backClick() {
float nextXPos = Gdx.graphics.getWidth() + CB.scaledSizes.MARGIN;
if (listViews.size == 1) {
// remove all BackClickListener
while (listBackClickListener.size > 0) {
StageManager.unRegisterForBackKey(listBackClickListener.pop());
}
//Send click to Cancel button
cancelClickListener.clicked(StageManager.BACK_KEY_INPUT_EVENT, -1, -1);
return;
}
StageManager.unRegisterForBackKey(listBackClickListener.pop());
listViewsNames.pop();
WidgetGroup actWidgetGroup = listViews.pop();
WidgetGroup showingWidgetGroup = listViews.get(listViews.size - 1);
float y = actWidgetGroup.getY();
actWidgetGroup.addAction(Actions.sequence(Actions.moveTo(nextXPos, y, Menu.MORE_MENU_ANIMATION_TIME), Actions.removeActor()));
showingWidgetGroup.addAction(Actions.moveTo(CB.scaledSizes.MARGIN, y, Menu.MORE_MENU_ANIMATION_TIME));
}
示例9: act
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override
public void act(float delta) {
super.act(delta);
if (lastTime == -1) lastTime = System.currentTimeMillis();
delta = ((System.currentTimeMillis() - lastTime) / 1000f);
lastTime = System.currentTimeMillis();
actTime += delta;
if (!fadeOutRuns && actTime > TIME_TO_FADE_OUT) {
this.addAction(Actions.alpha(style.alphaOff, 2f));
this.fadeOutRuns = true;
}
if (!fadeOutRuns) {
//wait for fade out
Gdx.graphics.requestRendering();
}
}
示例10: showWidgetGroup
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void showWidgetGroup() {
clearActions();
pack();
mainMenuWidgetGroup = new WidgetGroup();
mainMenuWidgetGroup.setName(this.name.toString());
mainMenuWidgetGroup.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight());
mainMenuWidgetGroup.addActor(this);
if (this.parentMenu == null) {
showingStage = StageManager.showOnNewStage(mainMenuWidgetGroup);
} else {
showingStage = StageManager.showOnActStage(mainMenuWidgetGroup);
}
if (this.parentMenu == null)
addAction(sequence(Actions.alpha(0), Actions.fadeIn(CB.WINDOW_FADE_TIME, Interpolation.fade)));
isShowing = true;
}
示例11: hide
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
public void hide(boolean all) {
if (this.onHideListener != null) {
this.onHideListener.onHide();
}
if (!isShowing) return;
if (this.parentMenu != null) {
if (all) {
StageManager.removeAllWithActStage(showingStage);
StageManager.unRegisterForBackKey(backClickListener);
} else {
float nextXPos = Gdx.graphics.getWidth() + CB.scaledSizes.MARGIN;
mainMenuWidgetGroup.addAction(Actions.sequence(Actions.moveTo(0 + nextXPos, 0, MORE_MENU_ANIMATION_TIME), Actions.removeActor()));
parentMenu.mainMenuWidgetGroup.addAction(Actions.moveTo(0, 0, MORE_MENU_ANIMATION_TIME));
}
} else {
super.hide();
StageManager.unRegisterForBackKey(backClickListener);
}
log.debug("Hide menu: " + this.name);
isShowing = false;
}
示例12: show
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override
public void show(final Stage stage, final Action action) {
bonuses.clear();
effects.clear();
box2d.create();
minionSprites.clear();
running = true;
timer = 0f;
background = gameAssetService.getRandomBackground();
for (final Table table : playerViews) {
table.setVisible(false);
}
createPlayerSprites();
createBlockSprites();
createMinionSprites();
super.show(stage, Actions.sequence(action, Actions.run(new Runnable() {
@Override
public void run() { // Listening to user input events:
final InputMultiplexer inputMultiplexer = new InputMultiplexer(stage);
box2d.initiateControls(inputMultiplexer);
Gdx.input.setInputProcessor(inputMultiplexer);
}
})));
}
示例13: showFreeze
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
private void showFreeze(final Creature creature) {
final TileSubView freeze = new TileSubView("creature-effect-freeze");
freeze.getActor().getColor().a = 0f;
final WorldObjectView view = visualizer.viewController.getView(creature);
view.addSubView(freeze);
freeze.getActor().addAction(alpha(1, 0.5f));
visualizer.viewController.world.dispatcher.add(Creature.REMOVE_EFFECT, new EventListener<EffectEvent>() {
@Override public void handle(EventType<EffectEvent> type, EffectEvent event) {
if (event.creature == creature && event.effect instanceof FreezeEffect) {
freeze.getActor().addAction(Actions.sequence(
Actions.alpha(0, 0.5f),
Actions.run(new Runnable() {
@Override public void run() {
view.removeSubView(freeze);
}
})
));
}
}
});
}
示例14: visualize
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override public IFuture<Void> visualize(final AddEffect result) {
final Array<TextureAtlas.AtlasRegion> regions = Config.findRegions("animation/effect-" + result.ability.name);
if (regions.size == 0)
return Future.completed();
final WorldObjectView view = visualizer.viewController.getView(result.getTarget());
final AnimationSubView subView = new AnimationSubView(0.1f, regions, Animation.PlayMode.LOOP);
subView.getActor().setPosition(1, 2);
subView.priority = 1;
view.addSubView(subView);
visualizer.viewController.world.dispatcher.add(Creature.REMOVE_EFFECT, new EventListener<EffectEvent>() {
@Override public void handle(EventType<EffectEvent> type, EffectEvent event) {
if (event.effect != result.effectToApply || event.creature != result.creatureToAddEffect)
return;
visualizer.viewController.world.dispatcher.remove(Creature.REMOVE_EFFECT, this);
SoundManager.instance.playMusicAsSound("boss-protection-loss");
subView.getActor().addAction(Actions.alpha(0, DURATION));
subView.getActor().addAction(Actions.delay(DURATION, Actions.run(new Runnable() {
@Override public void run() {
view.removeSubView(subView);
}
})));
}
});
return Future.completed();
}
示例15: visualize
import com.badlogic.gdx.scenes.scene2d.actions.Actions; //导入依赖的package包/类
@Override public IFuture<Void> visualize(PoisonShotResult result) {
final Future<Void> future = new Future<Void>();
final WorldObjectView actorView = visualizer.viewController.getView(result.creature);
WorldObjectView targetView = visualizer.viewController.getView(result.target);
Vector2 direction = tmp.set(result.target.getX(), result.target.getY()).sub(result.creature.getX(), result.creature.getY());
visualizer.viewController.scroller.centerOn(result.target);
float dx = targetView.getX() - actorView.getX();
float dy = targetView.getY() - actorView.getY();
final ImageSubView arrow = new ImageSubView("animation/poison-dart");
arrow.getActor().setOrigin(13, 14);
arrow.getActor().setRotation(direction.angle());
arrow.getActor().addAction(Actions.sequence(
Actions.moveBy(dx, dy, tmp.set(dx, dy).len() * 0.003f),
Actions.run(new Runnable() {
@Override public void run() {
SoundManager.instance.playSound("arrow-shot");
actorView.removeSubView(arrow);
future.happen();
}
})
));
actorView.addSubView(arrow);
return future;
}