Fixed scroll override bug

This commit is contained in:
Willem 2022-02-05 00:21:55 +01:00
parent 1efc29b370
commit bc02b51d7d
4 changed files with 26 additions and 15 deletions

View file

@ -11,7 +11,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain;
import love.distributedrebirth.gdxapp.Demo4DMainAdapter; import love.distributedrebirth.gdxapp.Demo4DMainAdapter;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
abstract public class ScrollScreenAdapter extends Demo4DMainAdapter { abstract public class AbstractScrollScreen extends Demo4DMainAdapter {
private static final int LINE_HEIGHT = 16; private static final int LINE_HEIGHT = 16;
private float scrollDeltaTime = 0f; private float scrollDeltaTime = 0f;
private String scrollText = ""; private String scrollText = "";
@ -19,7 +19,7 @@ abstract public class ScrollScreenAdapter extends Demo4DMainAdapter {
private int scrollLine = LINE_HEIGHT; private int scrollLine = LINE_HEIGHT;
private final Texture backgroundImage; private final Texture backgroundImage;
public ScrollScreenAdapter(final Demo4DMain main, String background) { public AbstractScrollScreen(final Demo4DMain main, String background) {
super(main); super(main);
backgroundImage = new Texture(Gdx.files.internal(background)); backgroundImage = new Texture(Gdx.files.internal(background));
} }
@ -64,19 +64,30 @@ abstract public class ScrollScreenAdapter extends Demo4DMainAdapter {
} }
@Override @Override
public void hide() { public final void show() {
showScroll();
}
protected void showScroll() {
}
@Override
public final void hide() {
scrollText = ""; scrollText = "";
scrollIndex = 0; scrollIndex = 0;
scrollLine = LINE_HEIGHT; scrollLine = LINE_HEIGHT;
hideScroll();
}
protected void hideScroll() {
} }
@Override @Override
public final void dispose() { public final void dispose() {
backgroundImage.dispose(); backgroundImage.dispose();
disposeScreen(main); disposeScroll();
} }
protected void disposeScreen(Demo4DMain main) { protected void disposeScroll() {
// override if needed
} }
} }

View file

@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain;
import love.distributedrebirth.gdxapp.music.MusicSongType; import love.distributedrebirth.gdxapp.music.MusicSongType;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class ScreenCredits extends ScrollScreenAdapter { public class ScreenCredits extends AbstractScrollScreen {
private final String creditsText = String.join("\n", private final String creditsText = String.join("\n",
"Credits;", "Credits;",
"At-Ohm-Allah-to-the-power-of-Four", "At-Ohm-Allah-to-the-power-of-Four",
@ -78,12 +78,12 @@ public class ScreenCredits extends ScrollScreenAdapter {
} }
@Override @Override
public void show () { public void showScroll() {
main.music.play(MusicSongType.CREDITS); main.music.play(MusicSongType.CREDITS);
} }
@Override @Override
public void hide () { public void hideScroll() {
main.music.play(MusicSongType.BACKGROUND); main.music.play(MusicSongType.BACKGROUND);
} }
} }

View file

@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain;
import love.distributedrebirth.gdxapp.music.MusicSongType; import love.distributedrebirth.gdxapp.music.MusicSongType;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class ScreenHelp extends ScrollScreenAdapter { public class ScreenHelp extends AbstractScrollScreen {
private final String creditsText = String.join("\n", private final String creditsText = String.join("\n",
"Genesis 11", "Genesis 11",
" ", " ",
@ -61,12 +61,12 @@ public class ScreenHelp extends ScrollScreenAdapter {
} }
@Override @Override
public void show () { public void showScroll() {
main.music.play(MusicSongType.INTRO); main.music.play(MusicSongType.INTRO);
} }
@Override @Override
public void hide () { public void hideScroll() {
main.music.play(MusicSongType.BACKGROUND); main.music.play(MusicSongType.BACKGROUND);
} }
} }

View file

@ -7,7 +7,7 @@ import love.distributedrebirth.gdxapp.Demo4DMain;
import love.distributedrebirth.gdxapp.music.MusicSongType; import love.distributedrebirth.gdxapp.music.MusicSongType;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class ScreenIntroMission extends ScrollScreenAdapter { public class ScreenIntroMission extends AbstractScrollScreen {
private final String missionText = String.join("\n", private final String missionText = String.join("\n",
"To a Waterfowl", "To a Waterfowl",
" -- by William Cullen Bryant --", " -- by William Cullen Bryant --",
@ -71,7 +71,7 @@ public class ScreenIntroMission extends ScrollScreenAdapter {
} }
@Override @Override
public void hide () { public void hideScroll() {
main.music.play(MusicSongType.BACKGROUND); main.music.play(MusicSongType.BACKGROUND);
} }
} }