gdxapp4d/main-gdxapp/src/main/love/distributedrebirth/gdxapp/screen/ScreenIntro.java

60 lines
1.7 KiB
Java
Raw Normal View History

package love.distributedrebirth.gdxapp.screen;
2022-01-28 14:04:24 +01:00
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.utils.ScreenUtils;
2022-02-04 14:39:25 +01:00
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
2022-02-07 00:09:29 +01:00
import love.distributedrebirth.gdxapp.GDXAppMain;
import love.distributedrebirth.gdxapp.music.MusicSongType;
2022-01-28 14:04:24 +01:00
2022-02-04 14:39:25 +01:00
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
2022-01-28 14:04:24 +01:00
public class ScreenIntro extends ScreenAdapter {
2022-02-07 00:09:29 +01:00
private final GDXAppMain main;
2022-01-28 14:04:24 +01:00
private Texture backgroundImage;
private float colorDeltaTime = 0f;
private boolean colorPositive = true;
2022-02-07 00:09:29 +01:00
public ScreenIntro(final GDXAppMain main) {
2022-01-28 14:04:24 +01:00
this.main = main;
backgroundImage = new Texture(Gdx.files.internal("background/temple-os.png"));
}
@Override
public void render(float delta) {
if (colorPositive) {
colorDeltaTime += Gdx.graphics.getDeltaTime()/2;
} else {
colorDeltaTime -= Gdx.graphics.getDeltaTime()/2;
}
if (colorDeltaTime > 1f) {
colorPositive = false;
} else if (colorDeltaTime < 0f) {
colorPositive = true;
}
ScreenUtils.clear(0.333f, colorDeltaTime, colorDeltaTime, 1);
main.batch.begin();
main.batch.draw(backgroundImage, 0, 0, main.viewWidth, main.viewHeight);
main.font.draw(main.batch, "Tap anywhere to begin!", main.viewWidth/2 - 73, 33);
main.batch.end();
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.ENTER) || Gdx.input.isKeyPressed(Keys.SPACE)) {
main.setScreen(new ScreenIntroMission(main));
dispose();
}
}
@Override
public void show() {
main.music.play(MusicSongType.INTRO);
}
@Override
public void dispose() {
backgroundImage.dispose();
}
}