|
23 | 23 | import java.util.Locale;
|
24 | 24 | import java.util.Map;
|
25 | 25 |
|
| 26 | +import com.badlogic.gdx.Application.ApplicationType; |
26 | 27 | import com.badlogic.gdx.Gdx;
|
27 | 28 | import com.badlogic.gdx.Input;
|
28 | 29 | import com.badlogic.gdx.InputAdapter;
|
@@ -70,8 +71,7 @@ public class CreditsScreen extends ScreenAdapter implements BladeScreen {
|
70 | 71 | private final InputProcessor inputProcessor = new InputAdapter() {
|
71 | 72 | @Override
|
72 | 73 | public boolean keyUp(int keycode) {
|
73 |
| - if (keycode == Input.Keys.ESCAPE |
74 |
| - || keycode == Input.Keys.BACK) |
| 74 | + if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK) |
75 | 75 | ui.setCurrentScreen(Screens.MENU_SCREEN);
|
76 | 76 |
|
77 | 77 | return true;
|
@@ -110,31 +110,32 @@ public void render(float delta) {
|
110 | 110 | for (int i = stringHead; i < credits.size(); i++) {
|
111 | 111 | String s = credits.get(i);
|
112 | 112 |
|
113 |
| - char type = 'c'; // types are 'c' -> credit, 't' -> title, 'i' -> image, 's' -> space, 'm' -> music |
| 113 | + char type = 'c'; // types are 'c' -> credit, 't' -> title, 'i' -> image, 's' -> space, 'm' -> |
| 114 | + // music |
114 | 115 |
|
115 | 116 | if (s.indexOf('#') != -1) {
|
116 | 117 | type = s.charAt(0);
|
117 | 118 | s = s.substring(2);
|
118 | 119 | }
|
119 | 120 |
|
120 | 121 | switch (type) {
|
121 |
| - case 't': |
122 |
| - y = processCreditTitle(batch, width, height, y, i, s); |
123 |
| - break; |
124 |
| - case 'i': |
125 |
| - y = processCreditImage(batch, width, height, y, i, s); |
126 |
| - break; |
127 |
| - case 's': |
128 |
| - y = processCreditSpace(height, y, i, s); |
129 |
| - break; |
130 |
| - case 'm': |
131 |
| - processCreditMusic(s); |
132 |
| - credits.remove(i); |
133 |
| - i--; |
134 |
| - break; |
135 |
| - default: |
136 |
| - y = processCreditDefault(batch, width, height, y, i, s); |
137 |
| - break; |
| 122 | + case 't': |
| 123 | + y = processCreditTitle(batch, width, height, y, i, s); |
| 124 | + break; |
| 125 | + case 'i': |
| 126 | + y = processCreditImage(batch, width, height, y, i, s); |
| 127 | + break; |
| 128 | + case 's': |
| 129 | + y = processCreditSpace(height, y, i, s); |
| 130 | + break; |
| 131 | + case 'm': |
| 132 | + processCreditMusic(s); |
| 133 | + credits.remove(i); |
| 134 | + i--; |
| 135 | + break; |
| 136 | + default: |
| 137 | + y = processCreditDefault(batch, width, height, y, i, s); |
| 138 | + break; |
138 | 139 | }
|
139 | 140 |
|
140 | 141 | if (y < 0) {
|
@@ -188,22 +189,34 @@ private float processCreditSpace(int height, float y, int i, String s) {
|
188 | 189 | private void processCreditMusic(final String s) {
|
189 | 190 | if (music != null)
|
190 | 191 | music.dispose();
|
191 |
| - |
192 |
| - final String sound = EngineAssetManager.getInstance().checkIOSSoundName("music/" + s); |
| 192 | + |
| 193 | + final String file = EngineAssetManager.getInstance().checkIOSSoundName("music/" + s); |
193 | 194 |
|
194 | 195 | new Thread() {
|
195 | 196 | @Override
|
196 | 197 | public void run() {
|
197 |
| - music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(sound)); |
198 |
| - |
| 198 | + music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(file)); |
| 199 | + |
199 | 200 | try {
|
200 | 201 | music.play();
|
201 |
| - } catch(Exception e) { |
202 |
| - // sometimes the play method fails on desktop. |
203 |
| - EngineLogger.error("Error Playing music: " + s, e); |
| 202 | + music.setVolume(0.5f); |
| 203 | + } catch (Exception e) { |
| 204 | + |
| 205 | + // DEAL WITH OPENAL BUG |
| 206 | + if (Gdx.app.getType() == ApplicationType.Desktop && e.getMessage().contains("40963")) { |
| 207 | + EngineLogger.debug("!!!!!!!!!!!!!!!!!!!!!!!ERROR playing music trying again...!!!!!!!!!!!!!!!"); |
| 208 | + |
| 209 | + music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(file)); |
| 210 | + music.play(); |
| 211 | + music.setVolume(0.5f); |
| 212 | + |
| 213 | + return; |
| 214 | + } |
| 215 | + |
| 216 | + EngineLogger.error("Error Playing music: " + file); |
204 | 217 | }
|
205 | 218 | }
|
206 |
| - }.start(); |
| 219 | + }.start(); |
207 | 220 | }
|
208 | 221 |
|
209 | 222 | private float processCreditDefault(SpriteBatch batch, int width, int height, float y, int i, String s) {
|
@@ -307,7 +320,7 @@ public void drawCenteredScreenX(SpriteBatch batch, BitmapFont font, CharSequence
|
307 | 320 |
|
308 | 321 | layout.setText(font, str, Color.WHITE, viewportWidth, Align.center, true);
|
309 | 322 |
|
310 |
| - //x = (viewportWidth - layout.width)/2; |
| 323 | + // x = (viewportWidth - layout.width)/2; |
311 | 324 |
|
312 | 325 | font.draw(batch, layout, x, y);
|
313 | 326 | }
|
|
0 commit comments