@Override protected void onTrigger(PhysicsSprite s) throws Throwable { PlayableSprite sprite = (PlayableSprite) s; Player player1 = Players.getPlayer1(); Player player2 = Players.getPlayer(2); if (player2 == null || player2.getSprite() == null) { animateSprite(sprite); } else { sprite.freeze(); PlayableSprite toMove = null; if (player1.getSprite() == sprite) toMove = player2.getSprite(); else toMove = player1.getSprite(); // TODO Display dialog like "Over here!" toMove.freeze(); toMove.setMovementSpeed(20); toMove.setWaypoint(sprite.getX() - 20f, sprite.getY(), WaypointType.SMART); toMove.waitForEndOfWaypointQueue(); toMove.face(Direction.RIGHT); animateSprite(sprite); animateSprite(toMove); } finish(); }
private void animateSprite(PlayableSprite sprite) throws InterruptedException { sprite.setIsInvincible(true); sprite.setUsePhysics(false); sprite.freeze(); sprite.ignoreCollisionWith(RoofTopBeginning.exit); sprite.setMovementSpeed(3); sprite.setWaypoint(sprite.getX() - 48f, sprite.getY(), WaypointType.SIMPLE); sprite.waitForWaypointReached(); Thread.sleep(300); sprite.setMovementSpeed(30f); sprite.setWaypoint( sprite.getX() + RoofTopBeginning.exit.getX(), sprite.getY(), WaypointType.SIMPLE); Thread.sleep(300L); sprite.setVisible(false); sprite.clearWaypoints(); Camera.stopFollowing(sprite); sprite.setIsInvincible(false); }