Prevent flicker when moving planeswalker if not enough room for 3 rows on the screen at one time

This commit is contained in:
drdev
2016-11-12 22:01:51 +00:00
parent 2befbb1c99
commit d5bbbcc80c

View File

@@ -493,9 +493,14 @@ public class ConquestMultiverseScreen extends FScreen {
float w = getWidth(); float w = getWidth();
float regionHeight = w / CardRenderer.CARD_ART_RATIO; float regionHeight = w / CardRenderer.CARD_ART_RATIO;
float rowHeight = regionHeight / model.getCurrentPlane().getRowsPerRegion(); float rowHeight = regionHeight / model.getCurrentPlane().getRowsPerRegion();
float margin = rowHeight * 1.5f; //use rowHeight * 1.5f margin so an extra row is kept visible above and below your current location
float maxMargin = getHeight() / 2; //prevent flicker if rows too tall to fit 3 on screen at once
if (margin > maxMargin) {
margin = maxMargin;
}
Vector2 pos = activeMoveAnimation == null ? getPosition(model.getCurrentLocation()) : activeMoveAnimation.pos; Vector2 pos = activeMoveAnimation == null ? getPosition(model.getCurrentLocation()) : activeMoveAnimation.pos;
scrollIntoView(pos.x, pos.y - getScrollTop(), 0, 0, rowHeight * 1.5f); //use rowHeight * 1.5f margin so an extra row is kept visible above and below your current location scrollIntoView(pos.x, pos.y - getScrollTop(), 0, 0, margin);
} }
private class MoveAnimation extends ForgeAnimation { private class MoveAnimation extends ForgeAnimation {