List of usage examples for com.badlogic.gdx.math Interpolation pow3Out
PowOut pow3Out
To view the source code for com.badlogic.gdx.math Interpolation pow3Out.
Click Source Link
From source file:com.vlaaad.dice.states.GameMapState.java
License:Open Source License
@SuppressWarnings("unchecked") private void addGameServicesButtons() { final Table table = new Table(Config.skin); table.setFillParent(true);/*www . j a v a 2s.c om*/ table.bottom().left(); final Table content = new Table(); content.left(); table.add(content).expandX().fillX().height(22); stage.addActor(table); Config.mobileApi.services().dispatcher().addListener(new IStateDispatcher.Listener<ServicesState>() { final Ref<ActorGestureListener> listenerVar = new Ref<ActorGestureListener>(); final Table iconContainer = new Table(); boolean isShown; @Override public void onChangedState(ServicesState newState) { content.clearChildren(); if (newState == ServicesState.CONNECTED) { Group servicesButton = new Group(); Image image = new Image(Config.skin, "ui/button/services-up"); final Image notification = new Image(); notification.setScaling(Scaling.none); notification.setPosition(image.getWidth() - 1, image.getHeight() - 4); final Group arrow = new Group(); final Tile arrowUp = new Tile("ui/button/arrow-hide"); final Tile arrowDown = new Tile("ui/button/arrow-show"); image.setPosition(2, -1); arrowDown.getColor().a = 0; arrow.addActor(arrowUp); arrow.addActor(arrowDown); arrow.setSize(arrowUp.getWidth(), arrowUp.getHeight()); arrow.setOrigin(arrow.getWidth() / 2, arrow.getHeight() / 2); servicesButton.setSize(image.getWidth() + 1 + arrow.getWidth(), image.getHeight()); servicesButton.addActor(image); servicesButton.addActor(arrow); servicesButton.addActor(notification); arrow.setPosition(image.getWidth() + 1, image.getHeight() / 2 - arrow.getHeight() / 2); content.add(servicesButton); stage.getRoot().addActorBefore(table, iconContainer); iconContainer.clearChildren(); iconContainer.bottom().setFillParent(true); Table icons = new Table(Config.skin); icons.left().setBackground( Config.skin.newDrawable("particle-white-pixel", new Color(0, 0, 0, 0.25f))); icons.defaults().padBottom(-2); iconContainer.add(icons).expandX().fillX().height(22); icons.add().width(servicesButton.getWidth()).padRight(2); iconContainer.setY(-22); listenerVar.set(new ActorGestureListener() { @Override public void tap(InputEvent event, float x, float y, int count, int button) { notification.setDrawable(null); iconContainer.clearActions(); arrowUp.clearActions(); arrowDown.clearActions(); isShown = !isShown; Config.preferences.setServicesPaneShownByDefault(isShown); arrow.addAction(Actions.rotateBy(180, 0.25f, Interpolation.pow3Out)); if (isShown) { arrowDown.addAction(Actions.alpha(1, 0.25f, Interpolation.pow3Out)); arrowUp.addAction(Actions.alpha(0, 0.25f, Interpolation.pow3Out)); iconContainer.addAction(Actions.moveTo(0, 0, 0.25f, Interpolation.pow3Out)); } else { arrowDown.addAction(Actions.alpha(0, 0.25f, Interpolation.pow3Out)); arrowUp.addAction(Actions.alpha(1, 0.25f, Interpolation.pow3Out)); iconContainer.addAction(Actions.moveTo(0, -22, 0.25f, Interpolation.pow3Out)); } } }); servicesButton.addListener(listenerVar.get()); final Cell conflictCell = icons.add(); final Cell inviteCell = icons.add(); Button achievements = new Button(Config.skin, "achievements"); achievements.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Config.mobileApi.services().gameAchievements().showAchievements(); } }); icons.add(achievements).padLeft(4); Button leaderboards = new Button(Config.skin, "leaderboards"); leaderboards.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Config.mobileApi.services().showLeaderboard("CgkIsNnQ2ZcKEAIQFw"); } }); icons.add(leaderboards).padLeft(4); Button signOut = new Button(Config.skin, "sign-out"); signOut.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Config.mobileApi.services().signOut(); } }); icons.add(signOut).expandX().right().padRight(2); final Button conflict = new Button(Config.skin, "conflict"); conflict.addAction(Actions.forever( Actions.sequence(Actions.color(Color.valueOf("eb653c"), 0.5f, Interpolation.sine), Actions.color(Color.WHITE, 0.5f, Interpolation.sine)))); conflict.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { new ConflictWindow().show(new ConflictWindow.Params(userData, UserData.deserialize(callback.getConflictServerData()), new ConflictWindow.Callback() { @Override public void onResult(ConflictResolution conflictResolution) { callback.resolveConflictingState(conflictResolution); } })); } }); final Button invitesButton = new Button(Config.skin, "invite"); invitesButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { new BlockingWindow() .show(Config.mobileApi.services().multiplayer().displayInvitations()); } }); invitesButton.setColor(Color.GREEN); Config.mobileApi.services().multiplayer().invites() .addListener(new IStateDispatcher.Listener<Integer>() { @Override public void onChangedState(Integer invites) { // Logger.debug("invites count: " + invites); if (invites > 0) { if (!isShown) { notification .setDrawable(Config.skin.getDrawable("ui/button/notification")); } inviteCell.padLeft(4); inviteCell.setActor(invitesButton); } else { inviteCell.padRight(0); inviteCell.setActor(null); } } }, true); callback.dispatcher() .addListener(new IStateDispatcher.Listener<ConflictResolver.ResolverState>() { @Override public void onChangedState(ConflictResolver.ResolverState newState) { if (newState == ConflictResolver.ResolverState.hasConflict) { if (!isShown) { notification .setDrawable(Config.skin.getDrawable("ui/button/notification")); } conflictCell.padLeft(4); conflictCell.setActor(conflict); } else { conflictCell.padRight(0); conflictCell.setActor(null); } } }, true); if (!isShown && Config.preferences.isServicesPaneShownByDefault()) { listenerVar.get().tap(null, 0, 0, 0, 0); } } else { Button signIn = new Button(Config.skin, "services-sign-in"); signIn.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Config.mobileApi.services().signIn(); } }); content.add(signIn).left().padBottom(-4).padLeft(1); if (isShown && listenerVar.get() != null) { listenerVar.get().tap(null, 0, 0, 0, 0); Config.preferences.setServicesPaneShownByDefault(true); listenerVar.clear(); } } } }, true); }
From source file:org.ams.testapps.paintandphysics.physicspuzzle.PhysicsPuzzle.java
License:Open Source License
/** Make some visual effect when a block is locked in. */ private void popAnimation(Vector2 pos) { // find a free popper PPPolygon popper = null;/*from w ww . j a v a2s . co m*/ for (PPPolygon polygon : poppers) { if (polygon.getOutlinePolygons().first().getOpacity() <= 0) { popper = polygon; break; } } if (popper == null) return; // no free poppers :( final PPPolygon finalPopper = popper; // prepare animation finalPopper.setPosition(pos); finalPopper.setOpacity(1f); finalPopper.setScale(1f); final float duration = 0.5f; timer.runOnRender(new Runnable() { long begin = System.currentTimeMillis(); @Override public void run() { long now = System.currentTimeMillis(); float alpha = 0.001f * (now - begin) / duration; float opacity = 1 - Interpolation.pow3Out.apply(alpha); float scale = 1 + Interpolation.pow3Out.apply(alpha); finalPopper.setOpacity(opacity); finalPopper.setScale(scale); if (opacity <= 0) { timer.remove(this); } } }); }
From source file:org.ams.testapps.paintandphysics.physicspuzzle.PhysicsPuzzle.java
License:Open Source License
private void activateNextBlock() { if (blocksLeft.size == 0) return;/* w ww . j a v a2 s.c o m*/ // determine which block is next PPPolygon block; int col, row; if (varyingSpawnColumn) { int lowestPlatform = potentialPlatformLevels.first(); for (int i = 1; i < potentialPlatformLevels.size; i++) { if (potentialPlatformLevels.get(i) < lowestPlatform) { lowestPlatform = potentialPlatformLevels.get(i); } } int lowestPossibleRow = lowestPlatform; int highestAllowedRow = lowestPossibleRow + maxTowerHeight; // select a random block that can be locked in do { col = MathUtils.random(columns - 1); row = potentialPlatformLevels.get(col) + 1; } while (row >= rows || row > highestAllowedRow); block = getBlock(row, col); blocksLeft.removeValue(block, true); } else { block = blocksLeft.get(0); col = getColumn(block); blocksLeft.removeIndex(0); } // position block float x = 0; if (varyingSpawnPosition) { // find suitable x coordinate // find a column that is not the target column of the block int _col; do { _col = MathUtils.random(columns - 1); } while (_col == col); float rowWidth = blockDim * columns; float halfRowWidth = rowWidth * 0.5f; float halfBlockDim = blockDim * 0.5f; x = -halfRowWidth + halfBlockDim; x += blockDim * _col; } block.setPosition(x, rows * blockDim * 0.5f + blockDim * 3); block.setVisible(true); block.getPhysicsThing().getBody().setActive(true); activeBlocks.add(block); // prepare spawning animation block.setScale(0); final float duration = 0.5f; final PPPolygon finalBlock = block; timer.runOnRender(new Runnable() { long begin = System.currentTimeMillis(); @Override public void run() { long now = System.currentTimeMillis(); float alpha = 0.001f * (now - begin) / duration; float scale = Interpolation.pow3Out.apply(alpha); if (scale > 1) { timer.remove(this); } finalBlock.setScale(scale); } }); potentialPlatformLevels.set(col, getRow(block)); bodyMover.setSelectedThing((ThingWithBody) block.getPhysicsThing()); }