@Test @NeedGL public void shouldParseSpriteView() throws Exception { CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("animation/MainScene.json"), null, null, null, null); Group group = editor.createGroup(); Image image = group.findActor("st_2"); Array<Action> actions = image.getActions(); assertThat(actions.size, is(1)); RepeatAction repeatAction = (RepeatAction) actions.get(0); ParallelAction parallelAction = (ParallelAction) repeatAction.getAction(); assertThat(parallelAction.getActions().size, is(3)); assertThat(parallelAction.getActions(), (Matcher) everyItem(instanceOf(SequenceAction.class))); SequenceAction moveAction = (SequenceAction) parallelAction.getActions().get(0); SequenceAction scaleAction = (SequenceAction) parallelAction.getActions().get(1); assertThat(moveAction.getActions().size, is(4)); assertThat(moveAction.getActions(), (Matcher) everyItem(instanceOf(MoveToAction.class))); assertThat(scaleAction.getActions().size, is(4)); assertThat(scaleAction.getActions(), (Matcher) everyItem(instanceOf(ScaleToAction.class))); }
public void displayContextMenu(Table content, boolean lock, ButtonKeyboardHelper keyboardHelper) { if (lockContextMenu) { return; } lockContextMenu = lock; if ( !created ) { create(); created = true; } contextMenu = new Tooltip( content, skin, stage ); contextMenu.setWidth( stage.getWidth() - ( abilityPanel.getWidth() + equipmentPanel.getWidth() + 40 ) ); contextMenu.setHeight( stage.getHeight() - ( buttonsPanel.getHeight() + 40 ) ); contextMenu.show( stage.getWidth() / 2 - contextMenu.getWidth() / 2 - 10, stage.getHeight() / 2 - contextMenu.getHeight() / 2 - 30, lock ); ParallelAction parallelAction = new ParallelAction( new SequenceAction( Actions.alpha( 0 ), Actions.fadeIn( 0.25f ) ), new SequenceAction( Actions.scaleTo( 0, 0 ), Actions.scaleTo( 1, 1, 0.25f ) ) ); contextMenu.addAction( new SequenceAction( parallelAction, Actions.removeAction( parallelAction ) ) ); this.keyboardHelper = keyboardHelper; }
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); escenario.draw(); escenario.act(); if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) { ParallelAction par = new ParallelAction(); par.addAction(Actions.moveTo(250, 250, 1)); par.addAction(Actions.color(Color.BLUE, 1)); coche.addAction(par); } }
/** * Konstruktor. */ public MainMenu() { float moveToDuration = width / 5 / 30; initStage(this.getViewport(), this.getSpriteBatch()); initTable(); // Table = Gridlayout addBackground(); initButtons(); // To be called after initTable (adds itself to table) setupEventListeners(); stage.addActor(table); player = new PlayerImpl(); player.setPosition(0, 0.13f * height); // player.scaleBy(0.5F); player.setAnimationSpeed(0.4f); stage.addActor(player); ParallelAction toRight = Actions.parallel(Actions.moveTo(width + 50, player.getY(), moveToDuration), new AnimationAction(Direction.RIGHT, moveToDuration)); ParallelAction toLeft = Actions.parallel( Actions.moveTo(-100 - player.getWidth(), player.getY(), moveToDuration), new AnimationAction( Direction.LEFT, moveToDuration)); player.addAction(Actions.forever(Actions.sequence(toRight, toLeft))); AssetManager.loadMusic("mainMenu"); AssetManager.loadSounds("worldmap"); music = audioManager.getMusic("mainMenu", "belotti.mp3"); if (!music.isPlaying()) { music.setLooping(true); music.play(); } }
/** * Sets the root group in its initial position, fitting the view */ public void fit(boolean animated) { if (animated) { sceneContainer.addAction(new SequenceAction(new ParallelAction( Actions.moveTo(0, 0, TIME, Interpolation.exp5Out), Actions .scaleTo(fitZoom, fitZoom, TIME, Interpolation.exp5Out)), Actions .run(containerUpdated))); } else { sceneContainer.setPosition(0.0f, 0.0f); sceneContainer.setScale(fitZoom, fitZoom); fireContainerUpdated(); } }