began testing, working through various errors, ended on constant
reloading in the game manager;
This commit is contained in:
@@ -2,6 +2,16 @@ package zero1hd.rhythmbullet;
|
||||
|
||||
import com.badlogic.gdx.Screen;
|
||||
|
||||
public interface InitialScreen {
|
||||
public Screen createMainScreen(RhythmBullet game);
|
||||
public interface InitialScreen extends Screen {
|
||||
/**
|
||||
* Screen should be created on platform.
|
||||
* @param gameManager the game manager.
|
||||
* @return the screen that is created.
|
||||
*/
|
||||
public Screen createMainScreen(RhythmBullet gameManager);
|
||||
|
||||
/**
|
||||
* Immediately called after the LibGDX instance has been instantiated.
|
||||
*/
|
||||
public void init();
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ public class RhythmBullet extends Game {
|
||||
public static int pixels_per_unit;
|
||||
private boolean initiated;
|
||||
private boolean resizing;
|
||||
private boolean completeUILoad;
|
||||
private int screenWidth, screenHeight;
|
||||
public static final String VERSION = "(0.1)R1-PreAlpha";
|
||||
|
||||
@@ -38,7 +39,7 @@ public class RhythmBullet extends Game {
|
||||
TextureAtlas skinAtlas;
|
||||
private Preferences preferences;
|
||||
private RoundingResolutionHandler rRHandler;
|
||||
private Screen initialScreen;
|
||||
private InitialScreen initialScreen;
|
||||
private AssetPack assetPack;
|
||||
|
||||
/**
|
||||
@@ -46,7 +47,7 @@ public class RhythmBullet extends Game {
|
||||
* @param initialScreen the first screen to go to.
|
||||
* @param assetPack the asset package to be used.
|
||||
*/
|
||||
public void setup(Screen initialScreen, AssetPack assetPack) {
|
||||
public void setup(InitialScreen initialScreen, AssetPack assetPack) {
|
||||
this.initialScreen = initialScreen;
|
||||
this.assetPack = assetPack;
|
||||
}
|
||||
@@ -54,6 +55,7 @@ public class RhythmBullet extends Game {
|
||||
@Override
|
||||
public void create() {
|
||||
Gdx.app.setLogLevel(Application.LOG_DEBUG);
|
||||
initialScreen.init();
|
||||
setScreen(initialScreen);
|
||||
|
||||
assetPack.initiateResources();
|
||||
@@ -101,17 +103,16 @@ public class RhythmBullet extends Game {
|
||||
|
||||
public boolean checkAssetQueue() {
|
||||
if (assetManager.update()) {
|
||||
if (skin != null) skin.dispose();
|
||||
skin = new Skin();
|
||||
skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class);
|
||||
getSkin().addRegions(skinAtlas);
|
||||
|
||||
assetPack.generateFonts(skin);
|
||||
assetPack.setupSkin(skin);
|
||||
assetPack.complete(assetManager);
|
||||
|
||||
if (resizing) {
|
||||
Gdx.app.debug("Resize", "Post resize is starting...");
|
||||
if (skin != null) skin.dispose();
|
||||
skin = new Skin();
|
||||
skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class);
|
||||
getSkin().addRegions(skinAtlas);
|
||||
|
||||
assetPack.generateFonts(skin);
|
||||
assetPack.setupSkin(skin);
|
||||
assetPack.complete(assetManager);
|
||||
if (getScreen() instanceof ResizeReadyScreen) {
|
||||
((ResizeReadyScreen) getScreen()).postAssetLoad();
|
||||
} else {
|
||||
|
@@ -161,15 +161,16 @@ public class MusicController extends Observable implements OnCompletionListener,
|
||||
if (currentlyPlayingIndex >= musicList.getTotal()) {
|
||||
currentlyPlayingIndex = 0;
|
||||
}
|
||||
this.music = Gdx.audio.newMusic(musicList.getMusicArray().get(currentlyPlayingIndex));
|
||||
music.setOnCompletionListener(this);
|
||||
|
||||
setChanged();
|
||||
|
||||
if (autoPlay) {
|
||||
play();
|
||||
if (musicList.getTotal() != 0) {
|
||||
this.music = Gdx.audio.newMusic(musicList.getMusicArray().get(currentlyPlayingIndex));
|
||||
music.setOnCompletionListener(this);
|
||||
|
||||
setChanged();
|
||||
if (autoPlay) {
|
||||
play();
|
||||
}
|
||||
notifyObservers(states.LOADED);
|
||||
}
|
||||
notifyObservers(states.LOADED);
|
||||
}
|
||||
|
||||
public MusicList getMusicList() {
|
||||
|
@@ -18,7 +18,7 @@ public class MusicList extends Observable {
|
||||
private Array<FileHandle> musicList;
|
||||
private RecursiveMusicSearchThread searchThread;
|
||||
private AudioProcessorFactory audioProcFactory;
|
||||
private boolean searched;
|
||||
private volatile boolean searched;
|
||||
|
||||
public MusicList(AudioProcessorFactory audioProcessorFactory) {
|
||||
this.audioProcFactory = audioProcessorFactory;
|
||||
@@ -87,12 +87,6 @@ public class MusicList extends Observable {
|
||||
return searched;
|
||||
}
|
||||
|
||||
private void searchComplete() {
|
||||
notifyObservers();
|
||||
searched = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the amount of audio files discovered.
|
||||
@@ -120,7 +114,9 @@ public class MusicList extends Observable {
|
||||
Array<FileHandle> obtainedAudioFiles = recursiveMusicSearch(directory);
|
||||
if (work) {
|
||||
musicList = obtainedAudioFiles;
|
||||
searchComplete();
|
||||
musicList.add(Gdx.files.internal("music/Alan Walker - Spectre.mp3"));
|
||||
notifyObservers();
|
||||
searched = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,21 +29,20 @@ public class DoubleHorizontalVisualizer {
|
||||
this.barWidth = width/barCount;
|
||||
this.spaceBetweenBars = (int) (barWidth * spacePercentage);
|
||||
this.barWidth -= spaceBetweenBars;
|
||||
pcm = PCMSystem;
|
||||
if (barWidth < 1) throw new IllegalArgumentException("The arguments you passed caused the bar width to be 0.");
|
||||
binsPerBar = (pcm.getWindowSize()/barCount);
|
||||
binsPerBar = (pcm.getFrequencyBins().length/barCount);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
pcm = PCMSystem;
|
||||
amplitudes = new int[barCount];
|
||||
barHeights = new int[barCount];
|
||||
shapeRenderer = new ShapeRenderer();
|
||||
shapeRenderer.set(ShapeType.Filled);
|
||||
}
|
||||
|
||||
public void act(float delta) {
|
||||
for (int bar = 0; bar < amplitudes.length; bar++) {
|
||||
float normalizedAmplitude = 0;
|
||||
for (int freq = bar*binsPerBar; freq < bar*binsPerBar + binsPerBar; freq++) {
|
||||
for (int freq = bar*binsPerBar; freq < (bar*binsPerBar) + binsPerBar; freq++) {
|
||||
normalizedAmplitude += Math.abs(pcm.getFrequencyBins()[freq]);
|
||||
}
|
||||
amplitudes[bar] = (int) (normalizedAmplitude*multiplier);
|
||||
@@ -53,7 +52,7 @@ public class DoubleHorizontalVisualizer {
|
||||
if (barHeights[bar] > amplitudes[bar]) barHeights[bar] = amplitudes[bar];
|
||||
|
||||
}
|
||||
for (int bar = 1; bar <= barHeights.length; bar++) {
|
||||
for (int bar = 0; bar < barHeights.length; bar++) {
|
||||
int smoothCount = 1;
|
||||
for (int range = 0; range < smoothRange; range++) {
|
||||
if (bar+range < amplitudes.length) {
|
||||
@@ -70,7 +69,7 @@ public class DoubleHorizontalVisualizer {
|
||||
}
|
||||
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
shapeRenderer.begin();
|
||||
shapeRenderer.begin(ShapeType.Filled);
|
||||
shapeRenderer.rect(x, y-2, width, y);
|
||||
shapeRenderer.rect(x, y+height, width, y+height+2);
|
||||
int beginX = x + spaceBetweenBars/2, beginY = y;
|
||||
|
Reference in New Issue
Block a user