code cleanup

This commit is contained in:
2018-08-16 23:25:36 -05:00
parent 901594608c
commit 1e98d34035
5 changed files with 38 additions and 42 deletions

View File

@@ -102,9 +102,29 @@ public class ScrollText extends Widget {
}
}
public void scroll(float delta) {
if (text1Offset >= -text1Width) {
text1Offset -= 60*delta;
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
text2Offset -= 60*delta;
if (text2Offset <= -text2Width) {
text2Offset = clipBounds.getWidth();
}
}
} else {
text2Offset -= 60*delta;
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
text1Offset = clipBounds.getWidth();
}
}
}
@Override
public void act(float delta) {
setSize(getWidth(), textHeight + 4);
clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
if (dupFirstText) {
if (text1Width > clipBounds.getWidth()) {
@@ -130,26 +150,6 @@ public class ScrollText extends Widget {
super.act(delta);
}
public void scroll(float delta) {
if (text1Offset >= -text1Width) {
text1Offset -= 60*delta;
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
text2Offset -= 60*delta;
if (text2Offset <= -text2Width) {
text2Offset = clipBounds.getWidth();
}
}
} else {
text2Offset -= 60*delta;
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
text1Offset = clipBounds.getWidth();
}
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
if (background != null) {