Repository navigation
Expand file tree
/
Copy pathMyGdxGame.java
More file actions
97 lines (78 loc) · 2.34 KB
/
Copy pathMyGdxGame.java
File metadata and controls
97 lines (78 loc) · 2.34 KB
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
package com.thenewboston.gamesample;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MyGdxGame extends ApplicationAdapter implements InputProcessor {
private SpriteBatch batch;
//Declare sound objects
Sound gameOverSound;
Music clamJam;
@Override
public void create () {
batch = new SpriteBatch();
Gdx.input.setInputProcessor(this);
//Initialize and set input processor
gameOverSound = Gdx.audio.newSound(Gdx.files.internal("sounds/Death2.wav"));
clamJam = Gdx.audio.newMusic(Gdx.files.internal("sounds/clamJam.wav"));
}
@Override
public void dispose() {
//Make sure to dispose of it
gameOverSound.dispose();
clamJam.dispose();
batch.dispose();
}
@Override
public void render () {
Gdx.gl.glClearColor(1,1,1,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.end();
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
//Play the sound
//gameOverSound.play();
//Set pitch to 50% and volume to 90%
//long soundId = gameOverSound.play();
//gameOverSound.setPitch(soundId,0.5f);
//gameOverSound.setVolume(soundId,0.9f);
//Play streaming music
clamJam.play();
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
//Pauses the music, you can also stop() for starting over
clamJam.pause();
return true;
}
@Override
public boolean keyDown(int keycode) {
return false;
}
@Override
public boolean keyUp(int keycode) {
return false;
}
@Override
public boolean keyTyped(char character) {
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
return false;
}
@Override
public boolean scrolled(int amount) {
return false;
}
}