main menu particle effects
This commit is contained in:
@@ -21,6 +21,9 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
||||
private int binsPerBar;
|
||||
private float offset;
|
||||
private int boundaryThickness;
|
||||
private boolean significantBeat;
|
||||
private float maxAverageAmplitude;
|
||||
private byte significantFrames;
|
||||
private float targetDelta;
|
||||
private float spacePercentage = 0.7f;
|
||||
private float baseSensitivity = 0.009f;
|
||||
@@ -29,7 +32,7 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
||||
private int smoothRange = 2;
|
||||
private int binsToInclude = 120;
|
||||
private Color colorBegin = new Color(0.5f, 0.6f, 0.8f, 0.46f);
|
||||
private Color colorEnd = new Color();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param barCount amount of bars this visualizer should have.
|
||||
@@ -54,13 +57,37 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
||||
}
|
||||
|
||||
public void act(float delta) {
|
||||
if (pcm.hasAudioChanged()) {
|
||||
maxAverageAmplitude = 0;
|
||||
significantBeat = false;
|
||||
}
|
||||
float[] freqBins = pcm.getFrequencyBins();
|
||||
float averageAmplitude = 0;
|
||||
for (int bar = 0; bar < amplitudes.length; bar++) {
|
||||
amplitudes[bar] = 0;
|
||||
for (int freq = bar*binsPerBar; freq < (bar*binsPerBar) + binsPerBar; freq++) {
|
||||
amplitudes[bar] += Math.abs(freqBins[freq]) * baseSensitivity;
|
||||
}
|
||||
amplitudes[bar] /= binsPerBar;
|
||||
|
||||
averageAmplitude += amplitudes[bar];
|
||||
}
|
||||
|
||||
averageAmplitude /= amplitudes.length;
|
||||
if (averageAmplitude > maxAverageAmplitude*0.5f && !significantBeat) {
|
||||
if (maxAverageAmplitude != 0) {
|
||||
significantFrames++;
|
||||
if (significantFrames >= 16) {
|
||||
significantFrames = 0;
|
||||
significantBeat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (averageAmplitude > maxAverageAmplitude) {
|
||||
maxAverageAmplitude = averageAmplitude;
|
||||
}
|
||||
} else {
|
||||
significantBeat = false;
|
||||
}
|
||||
for (int bar = 0; bar < barHeights.length; bar++) {
|
||||
int smoothCount = 1;
|
||||
@@ -147,8 +174,12 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
||||
return y;
|
||||
}
|
||||
|
||||
public boolean isSignificantBeat() {
|
||||
return significantBeat;
|
||||
}
|
||||
|
||||
public void updateMusic() {
|
||||
pcm.updateMusic();
|
||||
pcm.loadMusic();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -8,5 +8,7 @@ public interface PCMSystem extends Disposable {
|
||||
|
||||
int getWindowSize();
|
||||
|
||||
void updateMusic();
|
||||
void loadMusic();
|
||||
|
||||
boolean hasAudioChanged();
|
||||
}
|
@@ -14,7 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Widget;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||
|
||||
public class ScrollText extends Widget {
|
||||
public class ScrollingText extends Widget {
|
||||
Rectangle scissors = new Rectangle();
|
||||
Rectangle clipBounds = new Rectangle();
|
||||
|
||||
@@ -35,13 +35,17 @@ public class ScrollText extends Widget {
|
||||
private NinePatch background;
|
||||
|
||||
private Vector2 coords;
|
||||
public ScrollText(String text, String text2, Skin skin, boolean scrollOnHover, boolean useBackground) {
|
||||
|
||||
private float targetDelta;
|
||||
|
||||
public ScrollingText(String text, String text2, Skin skin, boolean scrollOnHover, boolean useBackground, float targetDelta) {
|
||||
super();
|
||||
font = skin.getFont("default-font");
|
||||
init(text, text2, skin, scrollOnHover, useBackground);
|
||||
this.targetDelta = targetDelta;
|
||||
}
|
||||
|
||||
public ScrollText(String text, String text2, Skin skin, String fontName, Color color, boolean scrollOnHover, boolean useBackground) {
|
||||
public ScrollingText(String text, String text2, Skin skin, String fontName, Color color, boolean scrollOnHover, boolean useBackground) {
|
||||
super();
|
||||
font = skin.getFont(fontName);
|
||||
font.setColor(color);
|
||||
@@ -102,21 +106,18 @@ public class ScrollText extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void scroll(float delta) {
|
||||
if (text1Offset >= -text1Width) {
|
||||
text1Offset -= 60*delta;
|
||||
|
||||
|
||||
text1Offset -= 60*targetDelta;
|
||||
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
|
||||
text2Offset -= 60*delta;
|
||||
text2Offset -= 60*targetDelta;
|
||||
if (text2Offset <= -text2Width) {
|
||||
text2Offset = clipBounds.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
text2Offset -= 60*delta;
|
||||
text2Offset -= 60*targetDelta;
|
||||
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
|
||||
text1Offset = clipBounds.getWidth();
|
||||
}
|
Reference in New Issue
Block a user