@Override public void present(float deltaTime) { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); worldRender.render(deltaTime); if (isTreasure) { batcher.begin(); renderTreasure(treasureType); if (isTreasureSound) { Assets.playSound(Assets.treasureSound, game.soundState); isTreasureSound = false; } batcher.end(); } else if (isFinal) { batcher.begin(); renderFinal(); batcher.end(); } else { if (isPause && !isDialog) { batcher.begin(); renderGamePause(); batcher.end(); } } if ((isPause || !game.soundState) && bgMusic.isPlaying()) { bgMusic.pause(); } else if (!isPause && !bgMusic.isPlaying() && game.soundState) { Assets.playMusic(bgMusic, game.soundState); } }
public void playMusic() { music.setVolume(1); music.setLooping(true); if (music != null && !music.isPlaying()) { music.play(); } }
public void update(float delta) { // We draw the elements in order: from top to bottom. // so we need to order the array list for (SceneLayer layer : layers) layer.update(); // music delay update if (music != null && !music.isPlaying()) { boolean initialTime = false; if (currentMusicDelay <= initialMusicDelay) initialTime = true; currentMusicDelay += delta; if (initialTime) { if (currentMusicDelay > initialMusicDelay) playMusic(); } else { if (repeatMusicDelay >= 0 && currentMusicDelay > repeatMusicDelay + initialMusicDelay) { currentMusicDelay = initialMusicDelay; playMusic(); } } } for (BaseActor a : actors.values()) { a.update(delta); } camera.update(delta); if (followActor != null) { camera.updatePos(followActor); } }
// Metodo que devuelve una textura de un Arraylist cada X tiempo (intervalTime). private Texture SwapTextureFromArray( ArrayList<Texture> list, int startIndex, long startTime, float intervalTime) { Texture img = null; if (startIndex < list.size()) { Music sound = soundsList.get(startIndex); if (TimeUtils.timeSinceMillis(startTime) < intervalTime * 1000) { img = list.get(startIndex); if (startIndex < titlesList.size()) { imageTitle.ChangeFontText(titlesList.get(startIndex)); } if (!soundPlayed) { System.out.println("Playing music"); sound.play(); soundPlayed = true; } } else { if (!sound.isPlaying()) { actualImgIndex++; beginTime = TimeUtils.millis(); img = list.get(startIndex); imageTitle.ChangeFontText(titlesList.get(startIndex)); System.out.println("Music finished"); soundPlayed = false; } } } else { img = list.get(texturesList.size() - 1); } return img; }
@Override public void write(Json json) { json.writeValue("layers", layers); json.writeValue("id", id); json.writeValue("state", state, state == null ? null : state.getClass()); json.writeValue("verbs", verbManager); json.writeValue("actors", actors); json.writeValue("player", player); json.writeValue("backgroundAtlas", backgroundAtlas); json.writeValue("backgroundRegionId", backgroundRegionId); json.writeValue("lightMapAtlas", lightMapAtlas); json.writeValue("lightMapRegionId", lightMapRegionId); json.writeValue("musicFilename", musicFilename); json.writeValue("loopMusic", loopMusic); json.writeValue("initialMusicDelay", initialMusicDelay); json.writeValue("repeatMusicDelay", repeatMusicDelay); json.writeValue("isPlaying", music != null && music.isPlaying()); json.writeValue("musicPos", music != null && music.isPlaying() ? music.getPosition() : 0f); json.writeValue("camera", camera); json.writeValue( "followActor", followActor == null ? null : followActor.getId(), followActor == null ? null : String.class); json.writeValue("depthVector", depthVector); json.writeValue( "polygonalNavGraph", polygonalNavGraph, polygonalNavGraph == null ? null : PolygonalNavGraph.class); }
private static void dispose() { if (music1.isPlaying()) music1.stop(); music1.dispose(); if (music2.isPlaying()) music2.stop(); music2.dispose(); }
public boolean isMusicPlaying() { return music.isPlaying(); }
public void stopMusic() { if (music != null && music.isPlaying()) { music.stop(); } }
public void pauseMusic() { if (music != null && music.isPlaying()) { music.pause(); isMusicPaused = true; } }
public void playMusic() { if (music != null && !music.isPlaying()) { music.play(); music.setLooping(loopMusic); } }
public static boolean isPlaying() { if (!(music == null)) return music.isPlaying(); return false; }