@Override protected void onUpdate(double progress) { if (progress > 1) { progress = 1; } model.setX((int) Math.round(progress * targetX + (1 - progress) * model.getX())); model.setY((int) Math.round(progress * targetY + (1 - progress) * model.getY())); model.notifyUpdate(); }
/** Limits value to [min, max], so that min <= value <= max. */ private static int limit(int min, int value, int max) { return Math.min(Math.max(min, value), max); }