Skip to content
Snippets Groups Projects
Commit 04708c62 authored by ALGLAVE Ivan's avatar ALGLAVE Ivan
Browse files

Adding assets files to desktop version, Game now shows intro image for 2...

Adding assets files to desktop version, Game now shows intro image for 2 seconds then switches to Menu, displaying the Menu image. No interaction implemented yet.
parent 5afd9936
Branches
No related tags found
No related merge requests found
package com.mygdx.game.GameScreens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.mygdx.game.singletons.FontManager;
import java.util.Date;
......@@ -11,21 +17,30 @@ import java.util.Date;
*/
public class GameIntro extends GameScreen
{
BitmapFont bf = new BitmapFont();
long creationDate;
Texture intro;
String s;
@Override
public void buildStage() {
/*Label l = new Label("Intro screen", FontManager.getInstance().getLabelStyle(Color.BLACK));
l.setPosition(50, 50);
addActor(l);*/
creationDate = System.currentTimeMillis();
bf.setColor(Color.RED);
intro = new Texture(Gdx.files.internal("images/Intro.jpg"));
}
@Override
public void render(float delta) {
public void render(float delta)
{
beforeRender();
// Add logic
batch.draw(intro, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
if(System.currentTimeMillis() - creationDate > 2000)
{
......
package com.mygdx.game.GameScreens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
/**
* Menu screen containing the 1-2 players options and a quit button
* Shown after the introduction
*/
public class GameMenu extends GameScreen {
@Override
public void buildStage() {
public class GameMenu extends GameScreen
{
Texture menu;
@Override
public void buildStage()
{
menu = new Texture(Gdx.files.internal("images/Menu.jpg"));
}
@Override
public void render(float delta) {
beforeRender();
batch.draw(menu, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
super.render(delta);
}
}
package com.mygdx.game.GameScreens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
/**
* Gameplay screen, allowing the user to play against an IA or another player on a shared screen
* Upon exit or end of the game, shows the Menu
......@@ -8,6 +12,12 @@ public class GamePlay extends GameScreen
{
@Override
public void buildStage() {
}
@Override
public void render(float delta) {
beforeRender();
super.render(delta);
}
}
......@@ -4,13 +4,17 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.StretchViewport;
/**
* Abstract class implemented by any game screen used by the GameScreenManager
*/
public abstract class GameScreen extends Stage implements Screen {
public abstract class GameScreen extends Stage implements Screen
{
SpriteBatch batch = new SpriteBatch();
protected GameScreen() {
super( new StretchViewport(320.0f, 240.0f, new OrthographicCamera()) );
......@@ -21,12 +25,18 @@ public abstract class GameScreen extends Stage implements Screen {
*/
public abstract void buildStage();
@Override
public void render(float delta)
protected void beforeRender()
{
// Clear screen
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
}
@Override
public void render(float delta)
{
batch.end();
// Calling to Stage methods
super.act(delta);
super.draw();
......
......@@ -25,7 +25,7 @@ public class FontManager
public BitmapFont generateFont()
{
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("HFF Ice Bergman.ttf"));
/*FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("HFF Ice Bergman.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 30;
parameter.borderWidth = 1;
......@@ -36,14 +36,17 @@ public class FontManager
BitmapFont font = generator.generateFont(parameter); // font size 24 pixels
generator.dispose();
return font;
return font;*/
return null;
}
public Label.LabelStyle getLabelStyle(Color fontColor)
{
Label.LabelStyle l = new Label.LabelStyle();
/*Label.LabelStyle l = new Label.LabelStyle();
l.font = generateFont();
l.fontColor = fontColor;
return l;
return l;*/
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment