@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); }
@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)); }
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(); }
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); }
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)); } }
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); } }
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(); }) )); }
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)); }
@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(); } }
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; }
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; }
@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); } }))); }
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); } }) )); } } }); }
@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(); }
@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; }
@Override public IFuture<Void> visualize(DroppedItem drop) { final Future<Void> future = new Future<Void>(); Group group = new Group(); Tile image = new Tile("item/" + drop.item.name); Label counter = new Label(String.valueOf(drop.count), Config.skin); counter.setSize(image.getWidth(), image.getHeight()); counter.setAlignment(Align.right | Align.bottom); group.addActor(image); group.addActor(counter); group.setTransform(false); visualizer.viewController.notificationLayer.addActor(group); group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE); group.addAction(Actions.parallel( Actions.moveBy(0, 30, 1f, Interpolation.fade), Actions.alpha(0, 1f, Interpolation.fade), Actions.delay(0.4f, Actions.run(new Runnable() { @Override public void run() { future.happen(); } })) )); return future; }
@Override public IFuture<TurnResponse> process(final TurnParams params) { final Future<TurnResponse> future = new Future<TurnResponse>(); params.creature.world.stage.addAction(Actions.delay( ViewScroller.CENTER_ON_TIME, Actions.run(new Runnable() { @Override public void run() { Array<Ability> profAbilities = params.availableProfessionAbilities; RandomController r = params.creature.world.getController(RandomController.class); boolean move = profAbilities.size == 0 || r.randomBoolean(); if (move) { future.happen(new TurnResponse<Grid2D.Coordinate>(TurnResponse.TurnAction.MOVE, r.random(params.availableCells))); } else { future.happen(new TurnResponse<Ability>(TurnResponse.TurnAction.PROFESSION_ABILITY, r.random(params.availableProfessionAbilities))); } } }) )); return future; }
private void refreshStartButton() { startButton.setDisabled(placed.size == 0); startButton.clearActions(); if (placed.size == 0) { startButton.addAction(Actions.moveTo( world.stage.getWidth() / 2 - startButton.getWidth() / 2, world.stage.getHeight() + startButton.getHeight(), 0.5f, Interpolation.swingIn )); } else { startButton.addAction(Actions.moveTo( world.stage.getWidth() / 2 - startButton.getWidth() / 2, world.stage.getHeight() - startButton.getHeight() - 4, 0.5f, Interpolation.swingOut )); } }
@Override public void move(float delta) { float x = 0; float y = 0; if (!CustomUtils.outOfBoundsX(owner.getX(), owner.getWidth(), speed)) { x = speed; } if (!CustomUtils.outOfBoundsY(owner.getY(), owner.getHeight(), speed)) { y = speed; } owner.updatePositionAbsolute(x, y, false); lastX = x; lastY = y; if (sustainedDamage > 25) { for (SpriteActor segment : segments) { segment.remove(); } owner.addAction(Actions.removeActor()); } }
@Override public void act(float delta) { super.act(delta); if (configuration != null) { am.update(); int loadedCount = am.getLoadedAssets(); if (loadedCount < 1) { return; } timeSinceImageChange += delta; int interval = configuration.getChangeInterval(); if (getDrawable() == null) { needsNewBG = true; determineNextImageAction.act(delta); } else if (interval > 0 && timeSinceImageChange > interval && loadedCount > 1) { needsNewBG = true; addAction(Actions.sequence(Actions.fadeOut(0.1f), determineNextImageAction)); } } if (getStage() != null) { WindowPosition.CENTER.position(this); } }
public T isButton(final TClickListener clickListener) { actor.setTouchable(Touchable.enabled); actor.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); actor.addAction(Actions.sequence(Actions.scaleTo(0.9f, 0.9f, 0.1f), Actions.scaleTo(1, 1, 0.1f), Actions.run(new Runnable() { @Override public void run() { if (clickListener != null) { clickListener.onClick(actor); } } }))); } }); return this; }
public TImage isButton() { clearListeners(); origonCenter(); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); addAction(Actions.sequence(Actions.scaleTo(0.9f, 0.9f, 0.1f), Actions.scaleTo(1, 1, 0.1f), Actions.run(new Runnable() { @Override public void run() { if (clickListener != null) { clickListener.onClicked(TImage.this); } } }))); } }); return this; }
public void nextView() { Gdx.app.debug("PageView", "Change to next view"); SnapshotArray<Actor> children = this.getChildren(); if (children.get(children.size - 1).getX() <= 0) { Gdx.app.debug("PageView", "Already last one, can't move to next."); return; } Actor[] actors = children.begin(); float width = this.getWidth(); for (Actor actor : actors) { if (actor != null) { actor.addAction(Actions.moveTo(actor.getX() - width, 0, 0.5f)); } } children.end(); }
public void previousView() { Gdx.app.debug("PageView", "Change to previous view"); SnapshotArray<Actor> children = this.getChildren(); if (children.get(0).getX() >= 0) { Gdx.app.debug("PageView", "Already first one, can't move to previous."); return; } float width = this.getWidth(); Actor[] actors = children.begin(); for (Actor actor : actors) { if (actor != null) { actor.addAction(Actions.moveTo(actor.getX() + width, 0, 0.5f)); } } children.end(); }
@Override public void switchedTab(final Tab tab) { if (currentTab == null) { // Immediate transition: setNewTab(tab); } else if (hideActionProvider == null) { // Immediate transition: setNewTab(tab); } else { // Showing after the hiding action is done: final Table contentTable = getContentTable(tabbedPane); contentTable.clearActions(); contentTable.addAction(Actions.sequence(hideActionProvider.consume(currentTab), Actions.action(TabShowingAction.class).show(tab, this))); } }
public void takeDamage(int direction) { health--; hitSfx.play(); if (health <= 0) { die(); return; } addAction( sequence( parallel( Actions.moveBy(20 * direction, 0, 0.3f, Interpolation.circleOut), sequence(color(Color.BLACK, 0.15f), color(Color.WHITE, 0.15f))), Actions.moveTo(getX(), getY(), 0.1f, Interpolation.circleIn))); }
@Override public void create() { // Creating UI with gdx-lml-vis: stage = new Stage(new FitViewport(WIDTH, HEIGHT)); Gdx.input.setInputProcessor(stage); VisUI.load(); VisLml.parser().build().createView(this, Gdx.files.internal("core.lml")); // Smooth screen fading in: stage.addAction(Actions.sequence(Actions.alpha(0f), Actions.alpha(1f, 1f))); // Connecting with the server: for (final WebSocketTest test : tests) { test.setListener(this); test.connect("localhost"); } }
@Override public void show() { title.setPosition(game.SCREEN_WIDTH / 2 - title.getWidth() / 2, 800); //helpTip.setPosition(400-helpTip.getWidth()/2, 30); MoveToAction actionMove = Actions.action(MoveToAction.class); actionMove.setPosition(game.SCREEN_WIDTH / 2 - title.getWidth() / 2, 380); actionMove.setDuration(1); actionMove.setInterpolation(Interpolation.elasticOut); title.addAction(actionMove); if (!music.isPlaying()) { music = Assets.getManager().get("snd/menu_music.mp3", Music.class); music.play(); } showMenu(true); }
private void showMenu(boolean flag) { MoveToAction actionMove1 = Actions.action(MoveToAction.class);//out actionMove1.setPosition(game.SCREEN_WIDTH / 2, -200); actionMove1.setDuration(1); actionMove1.setInterpolation(Interpolation.swingIn); MoveToAction actionMove2 = Actions.action(MoveToAction.class);//in actionMove2.setPosition(game.SCREEN_WIDTH / 2, 190); actionMove2.setDuration(1f); actionMove2.setInterpolation(Interpolation.swing); if (flag) { table.addAction(actionMove2); options.addAction(actionMove1); } else { options.addAction(actionMove2); table.addAction(actionMove1); } menuShown = flag; exitShown = false; }
private void showExit(boolean flag) { MoveToAction actionMove1 = Actions.action(MoveToAction.class);//out actionMove1.setPosition(game.SCREEN_WIDTH / 2, -200); actionMove1.setDuration(1); actionMove1.setInterpolation(Interpolation.swingIn); MoveToAction actionMove2 = Actions.action(MoveToAction.class);//in actionMove2.setPosition(game.SCREEN_WIDTH / 2, 190); actionMove2.setDuration(1f); actionMove2.setInterpolation(Interpolation.swing); if (flag) { exit.addAction(actionMove2); table.addAction(actionMove1); } else { table.addAction(actionMove2); exit.addAction(actionMove1); } exitShown = flag; }
@Override public void show() { super.show(); canUpdate = false; swapBalls(); getStage().addAction(Actions.sequence( Actions.alpha(0), Actions.alpha(1, FADE_SPEED), Actions.run(new Runnable() { @Override public void run() { canUpdate = true; } }) )); }
@Override public void render(float delta) { super.render(delta); if (canUpdate && game.manager.update(1000 / 120)) { canUpdate = false; getStage().addAction(Actions.sequence( Actions.alpha(0, FADE_SPEED), Actions.delay(0.1f, Actions.run(new Runnable() { @Override public void run() { boardActor.remove(); ballAtlas.dispose(); ballsTexture.dispose(); game.finishLoading(); } })) )); } }
@Override public void show() { super.show(); // Hide all balls for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) boardActor.getBall(i, j).setVisible(false); canUpdate = false; getStage().addAction(Actions.sequence( Actions.alpha(0), Actions.alpha(1, FADE_SPEED), Actions.run(new Runnable() { @Override public void run() { canUpdate = true; } }) )); }
private ActionProvider getDefaultViewShowingActionProvider() { return new ActionProvider() { @Override public Action provideAction(final ViewController forController, final ViewController previousController) { if (musicService.getCurrentTheme() == null && GdxArrays.isNotEmpty(forController.getThemes())) { final Music currentTheme = forController.getThemes().random(); return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME), Actions.run(CommonActionRunnables.getMusicThemeSetterRunnable(musicService, currentTheme)), Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())), MusicFadingAction.fadeIn(currentTheme, MusicService.DEFAULT_THEME_FADING_TIME, musicService.getMusicVolume())); } return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME), Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage()))); } }; }
public void gameOverSetup () { retry = new Retry(); retry.getColor().a = 0; retry.addAction(Actions.parallel(Actions.fadeIn(1f),Actions.moveTo(RETRY_X * 100, RETRY_Y * 100, 1f, Interpolation.bounceOut))); stage.addActor(retry); retry.setZIndex(50); if ((int) playTime > game.highScore) { game.highScore = (int) playTime; game.pref.putInteger("Score", game.highScore); game.pref.flush(); } highScoreLabel = new Label(Integer.toString(game.highScore), game.labelStyle); highScoreLabel.setFontScale(1.5f); highScoreLabel.setPosition(VIRTUAL_WIDTH - highScoreLabel.getWidth(), VIRTUAL_HEIGHT - highScoreLabel.getHeight() - 300); highScoreLabel.setAlignment(Align.right); stage.addActor(highScoreLabel); stage.addActor(game.highScoreWordsLabel); highScoreLabel.getColor().a = game.highScoreWordsLabel.getColor().a = 0; highScoreLabel.setZIndex(50); game.highScoreWordsLabel.setZIndex(50); highScoreLabel.addAction(Actions.fadeIn(0.25f)); game.highScoreWordsLabel.addAction(Actions.fadeIn(0.25f)); }
public void setState(State newState) { mState = newState; if (newState == State.CRASHED) { mCrashedScene.clearActions(); mCrashedScene.addAction(Actions.fadeIn(0.3f)); ignoreInput(0.3f); } if (newState == State.FINISHED) { mFinishScene.addAction(Actions.fadeIn(0.5f)); ignoreInput(0.35f); } if (newState == State.PAUSE) { mPauseScene.setColor(1, 1, 1, 1); } if (newState == State.SHOW_MODAL) { ignoreInput(0.2f); mModalScene.addAction(Actions.fadeIn(0.3f)); } }
public void elinTransformToLadder() { if(marten.getScaleX()>0) item.addAction(Actions.moveTo(marten.getRight()-(spriterActor.getX()+spriterActor.getWidth()/2)-80, marten.getY(), 1f)); else item.addAction(Actions.moveTo(marten.getX()-(spriterActor.getX()+spriterActor.getWidth()/2)+10, marten.getY(), 1f)); item.addAction(Actions.sequence( Actions.run(new Runnable(){ @Override public void run() { setSpriterAnimationByName("transformation Echelle"); } }), Actions.delay(1.5f),Actions.run(new Runnable(){ @Override public void run() { spriterActor.setVisible(false); item.getImageById("ladder").setVisible(true); isLadder=true; goMarten=true; } }))); }
public void attack() { item.addAction(Actions.sequence(Actions.run(new Runnable(){ @Override public void run() { setSpriterAnimationByName("attaque"); blur.setVisible(true); isAttacking=true; }}), Actions.delay(.6f),Actions.run(new Runnable(){ @Override public void run() { isAttacking=true; blur.setVisible(false); setSpriterAnimationByName("debout"); }}),Actions.delay(1f),Actions.run(new Runnable(){ @Override public void run() { isAttacking=false; }}))); }
@Override public void act(float delta) { setX(getX()+direction*delta*moveSpeed); if(getX() > originalPosX + margin || getX() < originalPosX - margin) {direction*= -1; item.setScaleX(item.getScaleX()*-1); } item.setX(getX()); if(martenHitMonster()){ item.addAction(Actions.sequence(Actions.run(new Runnable(){ @Override public void run() { setSpriterAnimationByName("mort"); } }),Actions.delay(1f),Actions.run(new Runnable(){ @Override public void run() { item.remove(); item.getBody().setActive(false); } }))); } }