EHRE ALLA SPIEL GLEICH FERTIG

master
GammelJan 6 years ago
parent 50b0eb59dd
commit 60811f1229

@ -62,7 +62,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
gs = null; gs = null;
ws = null; ws = null;
levelAmount = 9; levelAmount = 9;
currentLevel = -1;
batch = new SpriteBatch(); batch = new SpriteBatch();
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);

@ -6,10 +6,13 @@
package view; package view;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
/** /**
@ -33,6 +36,10 @@ public class Winscreen{
boolean win; boolean win;
float winX;
float winY;
boolean movementWin;
int lvl; int lvl;
public Winscreen(float width, float height, boolean win, int lvl){ public Winscreen(float width, float height, boolean win, int lvl){
@ -43,7 +50,16 @@ public class Winscreen{
this.lvl = lvl; this.lvl = lvl;
if(win){ if(win){
movement = true;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 21;
font = generator.generateFont(parameter); // font size 12 pixels
generator.dispose(); // don't forget to dispose to avoid memory leaks!
font.setColor(Color.BLACK);
movementWin = true;
winSprite = new Sprite(new Texture(Gdx.files.internal("win.png"))); winSprite = new Sprite(new Texture(Gdx.files.internal("win.png")));
winSprite.setX(GAME_WORLD_WIDTH / 2 - winSprite.getWidth() / 2); winSprite.setX(GAME_WORLD_WIDTH / 2 - winSprite.getWidth() / 2);
winSprite.setY(GAME_WORLD_HEIGHT * 0.7f - winSprite.getHeight() / 2); winSprite.setY(GAME_WORLD_HEIGHT * 0.7f - winSprite.getHeight() / 2);
@ -63,16 +79,14 @@ public class Winscreen{
t.scheduleTask(new Timer.Task() { t.scheduleTask(new Timer.Task() {
@Override @Override
public void run() { public void run() {
if(winSprite.getY() < GAME_WORLD_HEIGHT*0.7){ if(winY < GAME_WORLD_HEIGHT * 0.7)
movement = true;} movementWin = true;
if(winSprite.getY() > GAME_WORLD_HEIGHT * 0.8){ else if(winY > GAME_WORLD_HEIGHT * 0.8)
movement = false;} movementWin = false;
if(movement){ if(movementWin)
winSprite.setY(winSprite.getY() + 3); winY = winY + 3;
} else
else{ winY = winY - 3;
winSprite.setY(winSprite.getY() - 3);
}
} }
},0 , 0.035f); },0 , 0.035f);
} }
@ -83,7 +97,12 @@ public class Winscreen{
if(lvl < 9 && win)next.draw(batch); if(lvl < 9 && win)next.draw(batch);
level.draw(batch); level.draw(batch);
reset.draw(batch); reset.draw(batch);
if(win)winSprite.draw(batch); if(win){
font.getData().setScale(2);
winX = GAME_WORLD_WIDTH / 2 - getTextWidth("click to start ...") / 2;
font.draw(batch, "click to start ...", winX, winY);
}
} }
public void dispose() { public void dispose() {
@ -92,4 +111,10 @@ public class Winscreen{
public boolean getWin(){ public boolean getWin(){
return win; return win;
} }
public float getTextWidth(String text){
GlyphLayout glyphLayout = new GlyphLayout();
String item = text;
glyphLayout.setText(font,item);
return glyphLayout.width;
}
} }

Loading…
Cancel
Save