1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture texture;
private Sprite sprite;
private BitmapFont font;
private Skin skin;
private Stage stage;
@Override
public void create() {
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("Eingangportal.png") );
skin = new Skin(Gdx.files.internal("glassy-ui.json"));
sprite = new Sprite(texture);
font = new BitmapFont();
font.setColor(Color.WHITE);
stage = new Stage();
this.butty("Characktäre",800, 800, new ClickListener(){
// @Override
public boolean touchDown(InputEvent event, float x, float y){
System.out.println("spiel starten");
return true;
//tu hier was
}
});
this.butty("Spiel starten",800, 700, new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
Gdx.app.log("Clicked button","Yep, you did");
System.out.println("spiel starten");
// startgame();
}
});
this.butty("Optionsmenu", 800, 600, new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
System.out.println("spiel starten");
//tu hier was
}
});
this.butty("Ruhmeshalle", 800, 500, new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
System.out.println("spiel starten");
//tu hier was
}
});
}
@Override
public void dispose() {
batch.dispose();
font.dispose();
texture.dispose();
stage.dispose();
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
sprite.draw(batch);
font.draw(batch, "Wilkommen zu Portale", 800, 900);
// font.draw(batch, "Characktäre", 800, 800);
// font.draw(batch, "Spiel starten", 800, 700);
// font.draw(batch, "Optionsmenu", 800, 600);
// font.draw(batch, "Ruhmeshalle", 800, 500);
batch.end();
stage.draw();
}
@Override
public void resize(int width, int height) {
}
private void butty(String buttname, int xpost, int ypost, ClickListener boom){
final TextButton charbut = new TextButton(buttname, skin, "default");
charbut.setWidth(200f);
charbut.setHeight(20f);
charbut.setPosition(xpost, ypost);
charbut.addListener(boom);
stage.addActor(charbut);
}
/* private void startgame(){
stage.dispose();
stage = new Stage();
font.draw(batch, "Wähle ein Spielart aus", 800, 900);
this.butty("inselgreifen",200, 800, new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
//tu hier was
}
});
}*/
}
|