|
|
|
|
@ -5,6 +5,8 @@ import com.badlogic.gdx.graphics.GL20;
|
|
|
|
|
import com.badlogic.gdx.graphics.Texture;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
|
|
|
|
import com.badlogic.gdx.utils.Timer;
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
|
|
|
|
|
|
|
|
public class View {
|
|
|
|
|
Texture b;
|
|
|
|
|
@ -13,14 +15,21 @@ public class View {
|
|
|
|
|
Sprite button;
|
|
|
|
|
Sprite title;
|
|
|
|
|
Sprite player;
|
|
|
|
|
int frame = 0;
|
|
|
|
|
int zeile = 0;
|
|
|
|
|
TextureRegion[][] regions;
|
|
|
|
|
Timer tunten;
|
|
|
|
|
Timer toben;
|
|
|
|
|
Timer tlinks;
|
|
|
|
|
Timer trechts;
|
|
|
|
|
|
|
|
|
|
public View() {
|
|
|
|
|
b = new Texture("Button.png");
|
|
|
|
|
t = new Texture("Title.png");
|
|
|
|
|
p = new Texture("Player.png");
|
|
|
|
|
p = new Texture("animplay.png");
|
|
|
|
|
button = new Sprite(b);
|
|
|
|
|
title = new Sprite(t);
|
|
|
|
|
player = new Sprite(p);
|
|
|
|
|
|
|
|
|
|
float w = Gdx.graphics.getWidth();
|
|
|
|
|
float h = Gdx.graphics.getHeight();
|
|
|
|
|
float wc = w/2;
|
|
|
|
|
@ -28,8 +37,86 @@ public class View {
|
|
|
|
|
title.setY(h - 200);
|
|
|
|
|
button.setX(wc - (button.getWidth()/2));
|
|
|
|
|
button.setY(400);
|
|
|
|
|
regions = TextureRegion.split(p, 32, 32);
|
|
|
|
|
player = new Sprite(regions[0][2]);
|
|
|
|
|
player.setX(200);
|
|
|
|
|
player.setY(200);
|
|
|
|
|
tunten = new Timer();
|
|
|
|
|
toben = new Timer();
|
|
|
|
|
tlinks = new Timer();
|
|
|
|
|
trechts = new Timer();
|
|
|
|
|
|
|
|
|
|
tunten.scheduleTask(new Timer.Task() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
zeile = 2;
|
|
|
|
|
|
|
|
|
|
if(frame == 9){
|
|
|
|
|
frame = 0;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
frame++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[zeile][frame]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},0,1/5f);
|
|
|
|
|
tunten.stop();
|
|
|
|
|
toben.scheduleTask(new Timer.Task() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
zeile = 2;
|
|
|
|
|
|
|
|
|
|
if(frame == 9){
|
|
|
|
|
frame = 0;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
frame++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[zeile][frame]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
toben.stop();
|
|
|
|
|
tlinks.scheduleTask(new Timer.Task() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
zeile = 2;
|
|
|
|
|
|
|
|
|
|
if(frame == 9){
|
|
|
|
|
frame = 0;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
frame++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[zeile][frame]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
tlinks.stop();
|
|
|
|
|
trechts.scheduleTask(new Timer.Task() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
zeile = 2;
|
|
|
|
|
|
|
|
|
|
if(frame == 9){
|
|
|
|
|
frame = 0;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
frame++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[zeile][frame]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
trechts.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,6 +125,19 @@ public class View {
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
player.setX(player.getX()+x);
|
|
|
|
|
player.setY(player.getY()+y);
|
|
|
|
|
if(x == 3f){
|
|
|
|
|
trechts.start();
|
|
|
|
|
}
|
|
|
|
|
if(x == -3f){
|
|
|
|
|
tlinks.start();
|
|
|
|
|
}
|
|
|
|
|
if(y == 3f){
|
|
|
|
|
toben.start();
|
|
|
|
|
}
|
|
|
|
|
if(y == -3f){
|
|
|
|
|
tunten.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch.begin();
|
|
|
|
|
title.draw(batch);
|
|
|
|
|
button.draw(batch);
|
|
|
|
|
@ -47,5 +147,17 @@ public class View {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void tuntenstop(){
|
|
|
|
|
tunten.stop();
|
|
|
|
|
frame = 0;}
|
|
|
|
|
public void tobenstop(){
|
|
|
|
|
toben.stop();
|
|
|
|
|
frame = 0;}
|
|
|
|
|
public void tlinksstop(){
|
|
|
|
|
tlinks.stop();
|
|
|
|
|
frame = 0;}
|
|
|
|
|
public void trechtsstop(){
|
|
|
|
|
trechts.stop();
|
|
|
|
|
frame = 0;}
|
|
|
|
|
|
|
|
|
|
}
|