-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
source/core/src/main/com/csse3200/game/screens/HelpScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.csse3200.game.screens; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.ScreenAdapter; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Image; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import com.badlogic.gdx.utils.viewport.FitViewport; | ||
import com.csse3200.game.GdxGame; | ||
|
||
public class HelpScreen extends ScreenAdapter { | ||
private final GdxGame game; | ||
private Stage stage; | ||
private SpriteBatch spriteBatch; | ||
|
||
public HelpScreen(GdxGame game) { | ||
this.game = game; | ||
stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); | ||
spriteBatch = new SpriteBatch(); | ||
|
||
// Create a table to organize the four image placeholders | ||
Table table = new Table(); | ||
table.setFillParent(true); // Makes the table the size of the stage | ||
|
||
// Create four image placeholders | ||
Image image1 = new Image(new Texture("images/lava_bg.png")); | ||
Image image2 = new Image(new Texture("images/lava_bg.png")); | ||
Image image3 = new Image(new Texture("images/lava_bg.png")); | ||
Image image4 = new Image(new Texture("images/lava_bg.png")); | ||
|
||
// Add the image placeholders to the table | ||
table.add(image1).expand().fill(); | ||
table.row(); // Move to the next row | ||
table.add(image2).expand().fill(); | ||
table.row(); | ||
table.add(image3).expand().fill(); | ||
table.row(); | ||
table.add(image4).expand().fill(); | ||
|
||
// Add the table to the stage | ||
stage.addActor(table); | ||
} | ||
|
||
@Override | ||
public void show() { | ||
// Set this screen as the input processor | ||
Gdx.input.setInputProcessor(stage); | ||
} | ||
|
||
@Override | ||
public void render(float delta) { | ||
// Clear the screen | ||
spriteBatch.begin(); | ||
spriteBatch.end(); | ||
|
||
// Draw the stage | ||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); | ||
stage.draw(); | ||
} | ||
|
||
@Override | ||
public void resize(int width, int height) { | ||
stage.getViewport().update(width, height, true); | ||
} | ||
|
||
@Override | ||
public void hide() { | ||
// Remove this screen as the input processor | ||
Gdx.input.setInputProcessor(null); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
stage.dispose(); | ||
spriteBatch.dispose(); | ||
} | ||
} |