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
No related branches found
No related tags found
No related merge requests found
package com.mygdx.game.GameScreens; package com.mygdx.game.GameScreens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; 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.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.mygdx.game.singletons.FontManager; import com.mygdx.game.singletons.FontManager;
import java.util.Date; import java.util.Date;
...@@ -11,21 +17,30 @@ import java.util.Date; ...@@ -11,21 +17,30 @@ import java.util.Date;
*/ */
public class GameIntro extends GameScreen public class GameIntro extends GameScreen
{ {
BitmapFont bf = new BitmapFont();
long creationDate; long creationDate;
Texture intro;
String s;
@Override @Override
public void buildStage() { public void buildStage() {
/*Label l = new Label("Intro screen", FontManager.getInstance().getLabelStyle(Color.BLACK)); /*Label l = new Label("Intro screen", FontManager.getInstance().getLabelStyle(Color.BLACK));
l.setPosition(50, 50); l.setPosition(50, 50);
addActor(l);*/ addActor(l);*/
creationDate = System.currentTimeMillis(); creationDate = System.currentTimeMillis();
bf.setColor(Color.RED);
intro = new Texture(Gdx.files.internal("images/Intro.jpg"));
} }
@Override @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) if(System.currentTimeMillis() - creationDate > 2000)
{ {
......
package com.mygdx.game.GameScreens; 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 * Menu screen containing the 1-2 players options and a quit button
* Shown after the introduction * Shown after the introduction
*/ */
public class GameMenu extends GameScreen { public class GameMenu extends GameScreen
@Override {
public void buildStage() { Texture menu;
@Override
public void buildStage()
{
menu = new Texture(Gdx.files.internal("images/Menu.jpg"));
} }
@Override @Override
public void render(float delta) { public void render(float delta) {
beforeRender();
batch.draw(menu, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
super.render(delta); super.render(delta);
} }
} }
package com.mygdx.game.GameScreens; 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 * 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 * Upon exit or end of the game, shows the Menu
...@@ -8,6 +12,12 @@ public class GamePlay extends GameScreen ...@@ -8,6 +12,12 @@ public class GamePlay extends GameScreen
{ {
@Override @Override
public void buildStage() { public void buildStage() {
}
@Override
public void render(float delta) {
beforeRender();
super.render(delta);
} }
} }
...@@ -4,13 +4,17 @@ import com.badlogic.gdx.Gdx; ...@@ -4,13 +4,17 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.StretchViewport; import com.badlogic.gdx.utils.viewport.StretchViewport;
/** /**
* Abstract class implemented by any game screen used by the GameScreenManager * 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() { protected GameScreen() {
super( new StretchViewport(320.0f, 240.0f, new OrthographicCamera()) ); super( new StretchViewport(320.0f, 240.0f, new OrthographicCamera()) );
...@@ -21,12 +25,18 @@ public abstract class GameScreen extends Stage implements Screen { ...@@ -21,12 +25,18 @@ public abstract class GameScreen extends Stage implements Screen {
*/ */
public abstract void buildStage(); public abstract void buildStage();
@Override protected void beforeRender()
public void render(float delta)
{ {
// Clear screen // Clear screen
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
}
@Override
public void render(float delta)
{
batch.end();
// Calling to Stage methods // Calling to Stage methods
super.act(delta); super.act(delta);
super.draw(); super.draw();
......
...@@ -25,7 +25,7 @@ public class FontManager ...@@ -25,7 +25,7 @@ public class FontManager
public BitmapFont generateFont() 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(); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 30; parameter.size = 30;
parameter.borderWidth = 1; parameter.borderWidth = 1;
...@@ -36,14 +36,17 @@ public class FontManager ...@@ -36,14 +36,17 @@ public class FontManager
BitmapFont font = generator.generateFont(parameter); // font size 24 pixels BitmapFont font = generator.generateFont(parameter); // font size 24 pixels
generator.dispose(); generator.dispose();
return font; return font;*/
return null;
} }
public Label.LabelStyle getLabelStyle(Color fontColor) public Label.LabelStyle getLabelStyle(Color fontColor)
{ {
Label.LabelStyle l = new Label.LabelStyle(); /*Label.LabelStyle l = new Label.LabelStyle();
l.font = generateFont(); l.font = generateFont();
l.fontColor = fontColor; 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