main menu particle effects
This commit is contained in:
parent
eb384e82ae
commit
34616142c6
@ -1,31 +1,27 @@
|
|||||||
beat
|
main
|
||||||
- Delay -
|
- Delay -
|
||||||
active: false
|
active: false
|
||||||
- Duration -
|
- Duration -
|
||||||
lowMin: 300.0
|
lowMin: 150.0
|
||||||
lowMax: 300.0
|
lowMax: 150.0
|
||||||
- Count -
|
- Count -
|
||||||
min: 0
|
min: 0
|
||||||
max: 50
|
max: 20
|
||||||
- Emission -
|
- Emission -
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 3.0
|
lowMax: 0.0
|
||||||
highMin: 50.0
|
highMin: 100.0
|
||||||
highMax: 60.0
|
highMax: 150.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 3
|
scalingCount: 1
|
||||||
scaling0: 1.0
|
scaling0: 1.0
|
||||||
scaling1: 0.19607843
|
timelineCount: 1
|
||||||
scaling2: 0.0
|
|
||||||
timelineCount: 3
|
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
timeline1: 0.20547946
|
|
||||||
timeline2: 1.0
|
|
||||||
- Life -
|
- Life -
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 0.0
|
lowMax: 0.0
|
||||||
highMin: 750.0
|
highMin: 2500.0
|
||||||
highMax: 1500.0
|
highMax: 3000.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 2
|
scalingCount: 2
|
||||||
scaling0: 1.0
|
scaling0: 1.0
|
||||||
@ -44,8 +40,8 @@ shape: line
|
|||||||
- Spawn Width -
|
- Spawn Width -
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 0.0
|
lowMax: 0.0
|
||||||
highMin: 64.0
|
highMin: 3840.0
|
||||||
highMax: 64.0
|
highMax: 3840.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 1
|
scalingCount: 1
|
||||||
scaling0: 1.0
|
scaling0: 1.0
|
||||||
@ -63,33 +59,33 @@ timelineCount: 1
|
|||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
- Scale -
|
- Scale -
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 0.5
|
lowMax: 0.0
|
||||||
highMin: 0.75
|
highMin: 45.0
|
||||||
highMax: 1.25
|
highMax: 135.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 5
|
scalingCount: 3
|
||||||
scaling0: 0.64705884
|
scaling0: 1.0
|
||||||
scaling1: 1.0
|
scaling1: 1.0
|
||||||
scaling2: 1.0
|
scaling2: 0.25490198
|
||||||
scaling3: 0.74509805
|
timelineCount: 3
|
||||||
scaling4: 0.3529412
|
|
||||||
timelineCount: 5
|
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
timeline1: 0.13013698
|
timeline1: 0.7876712
|
||||||
timeline2: 0.74657536
|
timeline2: 1.0
|
||||||
timeline3: 0.9246575
|
|
||||||
timeline4: 1.0
|
|
||||||
- Velocity -
|
- Velocity -
|
||||||
active: true
|
active: true
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 0.0
|
lowMax: 0.0
|
||||||
highMin: 15.0
|
highMin: 540.0
|
||||||
highMax: 30.0
|
highMax: 1080.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 1
|
scalingCount: 3
|
||||||
scaling0: 1.0
|
scaling0: 1.0
|
||||||
timelineCount: 1
|
scaling1: 1.0
|
||||||
|
scaling2: 0.6666667
|
||||||
|
timelineCount: 3
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
|
timeline1: 0.69863015
|
||||||
|
timeline2: 0.9931507
|
||||||
- Angle -
|
- Angle -
|
||||||
active: true
|
active: true
|
||||||
lowMin: 90.0
|
lowMin: 90.0
|
||||||
@ -99,75 +95,49 @@ highMax: 135.0
|
|||||||
relative: false
|
relative: false
|
||||||
scalingCount: 3
|
scalingCount: 3
|
||||||
scaling0: 1.0
|
scaling0: 1.0
|
||||||
scaling1: 0.0
|
scaling1: 0.43137255
|
||||||
scaling2: 0.0
|
scaling2: 0.13725491
|
||||||
timelineCount: 3
|
timelineCount: 3
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
timeline1: 0.5
|
timeline1: 0.5684931
|
||||||
timeline2: 1.0
|
timeline2: 0.8630137
|
||||||
- Rotation -
|
- Rotation -
|
||||||
active: true
|
active: false
|
||||||
lowMin: 0.0
|
|
||||||
lowMax: 0.0
|
|
||||||
highMin: 0.0
|
|
||||||
highMax: 360.0
|
|
||||||
relative: false
|
|
||||||
scalingCount: 2
|
|
||||||
scaling0: 0.0
|
|
||||||
scaling1: 1.0
|
|
||||||
timelineCount: 2
|
|
||||||
timeline0: 0.0
|
|
||||||
timeline1: 1.0
|
|
||||||
- Wind -
|
- Wind -
|
||||||
active: true
|
active: false
|
||||||
lowMin: 0.0
|
|
||||||
lowMax: 0.0
|
|
||||||
highMin: 0.0
|
|
||||||
highMax: 0.0
|
|
||||||
relative: false
|
|
||||||
scalingCount: 1
|
|
||||||
scaling0: 1.0
|
|
||||||
timelineCount: 1
|
|
||||||
timeline0: 0.0
|
|
||||||
- Gravity -
|
- Gravity -
|
||||||
active: false
|
active: false
|
||||||
- Tint -
|
- Tint -
|
||||||
colorsCount: 12
|
colorsCount: 6
|
||||||
colors0: 0.6431373
|
colors0: 0.050980393
|
||||||
colors1: 0.0
|
colors1: 0.74509805
|
||||||
colors2: 0.0
|
colors2: 1.0
|
||||||
colors3: 0.0
|
colors3: 0.02745098
|
||||||
colors4: 0.12941177
|
colors4: 0.41960785
|
||||||
colors5: 1.0
|
colors5: 0.56078434
|
||||||
colors6: 0.8784314
|
timelineCount: 2
|
||||||
colors7: 0.0
|
|
||||||
colors8: 1.0
|
|
||||||
colors9: 1.0
|
|
||||||
colors10: 0.9254902
|
|
||||||
colors11: 0.0
|
|
||||||
timelineCount: 4
|
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
timeline1: 0.5094081
|
timeline1: 1.0
|
||||||
timeline2: 0.7872049
|
|
||||||
timeline3: 1.0
|
|
||||||
- Transparency -
|
- Transparency -
|
||||||
lowMin: 0.0
|
lowMin: 0.0
|
||||||
lowMax: 0.0
|
lowMax: 0.0
|
||||||
highMin: 1.0
|
highMin: 1.0
|
||||||
highMax: 1.0
|
highMax: 1.0
|
||||||
relative: false
|
relative: false
|
||||||
scalingCount: 5
|
scalingCount: 6
|
||||||
scaling0: 0.2982456
|
scaling0: 0.0
|
||||||
scaling1: 0.64912283
|
scaling1: 0.19298245
|
||||||
scaling2: 0.80701756
|
scaling2: 1.0
|
||||||
scaling3: 0.47368422
|
scaling3: 1.0
|
||||||
scaling4: 0.0
|
scaling4: 0.21052632
|
||||||
timelineCount: 5
|
scaling5: 0.0
|
||||||
|
timelineCount: 6
|
||||||
timeline0: 0.0
|
timeline0: 0.0
|
||||||
timeline1: 0.28082192
|
timeline1: 0.23972602
|
||||||
timeline2: 0.6643836
|
timeline2: 0.41095892
|
||||||
timeline3: 0.8561644
|
timeline3: 0.60958904
|
||||||
timeline4: 1.0
|
timeline4: 0.79452056
|
||||||
|
timeline5: 1.0
|
||||||
- Options -
|
- Options -
|
||||||
attached: false
|
attached: false
|
||||||
continuous: false
|
continuous: false
|
||||||
@ -176,4 +146,4 @@ additive: true
|
|||||||
behind: false
|
behind: false
|
||||||
premultipliedAlpha: false
|
premultipliedAlpha: false
|
||||||
- Image Path -
|
- Image Path -
|
||||||
triangle.png
|
glow-circle.png
|
||||||
|
BIN
android/assets/particles/glow-circle.png
Executable file
BIN
android/assets/particles/glow-circle.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
@ -21,6 +21,9 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
private int binsPerBar;
|
private int binsPerBar;
|
||||||
private float offset;
|
private float offset;
|
||||||
private int boundaryThickness;
|
private int boundaryThickness;
|
||||||
|
private boolean significantBeat;
|
||||||
|
private float maxAverageAmplitude;
|
||||||
|
private byte significantFrames;
|
||||||
private float targetDelta;
|
private float targetDelta;
|
||||||
private float spacePercentage = 0.7f;
|
private float spacePercentage = 0.7f;
|
||||||
private float baseSensitivity = 0.009f;
|
private float baseSensitivity = 0.009f;
|
||||||
@ -29,7 +32,7 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
private int smoothRange = 2;
|
private int smoothRange = 2;
|
||||||
private int binsToInclude = 120;
|
private int binsToInclude = 120;
|
||||||
private Color colorBegin = new Color(0.5f, 0.6f, 0.8f, 0.46f);
|
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.
|
* @param barCount amount of bars this visualizer should have.
|
||||||
@ -54,13 +57,37 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
|
if (pcm.hasAudioChanged()) {
|
||||||
|
maxAverageAmplitude = 0;
|
||||||
|
significantBeat = false;
|
||||||
|
}
|
||||||
float[] freqBins = pcm.getFrequencyBins();
|
float[] freqBins = pcm.getFrequencyBins();
|
||||||
|
float averageAmplitude = 0;
|
||||||
for (int bar = 0; bar < amplitudes.length; bar++) {
|
for (int bar = 0; bar < amplitudes.length; bar++) {
|
||||||
amplitudes[bar] = 0;
|
amplitudes[bar] = 0;
|
||||||
for (int freq = bar*binsPerBar; freq < (bar*binsPerBar) + binsPerBar; freq++) {
|
for (int freq = bar*binsPerBar; freq < (bar*binsPerBar) + binsPerBar; freq++) {
|
||||||
amplitudes[bar] += Math.abs(freqBins[freq]) * baseSensitivity;
|
amplitudes[bar] += Math.abs(freqBins[freq]) * baseSensitivity;
|
||||||
}
|
}
|
||||||
amplitudes[bar] /= binsPerBar;
|
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++) {
|
for (int bar = 0; bar < barHeights.length; bar++) {
|
||||||
int smoothCount = 1;
|
int smoothCount = 1;
|
||||||
@ -147,8 +174,12 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSignificantBeat() {
|
||||||
|
return significantBeat;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMusic() {
|
public void updateMusic() {
|
||||||
pcm.updateMusic();
|
pcm.loadMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,5 +8,7 @@ public interface PCMSystem extends Disposable {
|
|||||||
|
|
||||||
int getWindowSize();
|
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.ClickListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||||
|
|
||||||
public class ScrollText extends Widget {
|
public class ScrollingText extends Widget {
|
||||||
Rectangle scissors = new Rectangle();
|
Rectangle scissors = new Rectangle();
|
||||||
Rectangle clipBounds = new Rectangle();
|
Rectangle clipBounds = new Rectangle();
|
||||||
|
|
||||||
@ -35,13 +35,17 @@ public class ScrollText extends Widget {
|
|||||||
private NinePatch background;
|
private NinePatch background;
|
||||||
|
|
||||||
private Vector2 coords;
|
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();
|
super();
|
||||||
font = skin.getFont("default-font");
|
font = skin.getFont("default-font");
|
||||||
init(text, text2, skin, scrollOnHover, useBackground);
|
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();
|
super();
|
||||||
font = skin.getFont(fontName);
|
font = skin.getFont(fontName);
|
||||||
font.setColor(color);
|
font.setColor(color);
|
||||||
@ -102,21 +106,18 @@ public class ScrollText extends Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void scroll(float delta) {
|
public void scroll(float delta) {
|
||||||
if (text1Offset >= -text1Width) {
|
if (text1Offset >= -text1Width) {
|
||||||
text1Offset -= 60*delta;
|
text1Offset -= 60*targetDelta;
|
||||||
|
|
||||||
|
|
||||||
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
|
if ((text1Offset < - Math.abs((text1Width - clipBounds.getWidth())) - 50) || text2Offset != clipBounds.getWidth()) {
|
||||||
text2Offset -= 60*delta;
|
text2Offset -= 60*targetDelta;
|
||||||
if (text2Offset <= -text2Width) {
|
if (text2Offset <= -text2Width) {
|
||||||
text2Offset = clipBounds.getWidth();
|
text2Offset = clipBounds.getWidth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
text2Offset -= 60*delta;
|
text2Offset -= 60*targetDelta;
|
||||||
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
|
if (text2Offset < - Math.abs((text2Width - clipBounds.getWidth())) - 50) {
|
||||||
text1Offset = clipBounds.getWidth();
|
text1Offset = clipBounds.getWidth();
|
||||||
}
|
}
|
@ -27,6 +27,7 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
private int windowSize = 1024;
|
private int windowSize = 1024;
|
||||||
private int sampleRate;
|
private int sampleRate;
|
||||||
private long millisPerWindow;
|
private long millisPerWindow;
|
||||||
|
private boolean songChanged;
|
||||||
private DecimalFormat df;
|
private DecimalFormat df;
|
||||||
private float[] PCM = new float[windowSize];
|
private float[] PCM = new float[windowSize];
|
||||||
private float[] frequencyBins = new float[windowSize / 2];
|
private float[] frequencyBins = new float[windowSize / 2];
|
||||||
@ -102,14 +103,14 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
synchronizeBufferWithPlayback();
|
synchronizeBufferWithPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calcBufferPosition() {
|
private int calculateBufferPosition() {
|
||||||
int offset = (int) alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET);
|
int offset = (int) alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET);
|
||||||
offset = (offset / windowSize) * windowSize;
|
offset = (offset / windowSize) * windowSize;
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean synchronizeBufferWithPlayback() {
|
private boolean synchronizeBufferWithPlayback() {
|
||||||
int bufferPos = calcBufferPosition();
|
int bufferPos = calculateBufferPosition();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (bufferPos <= playingBuffer.limit() && bufferPos >= 0) {
|
if (bufferPos <= playingBuffer.limit() && bufferPos >= 0) {
|
||||||
playingBuffer.position(bufferPos);
|
playingBuffer.position(bufferPos);
|
||||||
@ -121,7 +122,7 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMusic() {
|
public void loadMusic() {
|
||||||
Gdx.app.debug("PCMObtainer", "music set.");
|
Gdx.app.debug("PCMObtainer", "music set.");
|
||||||
sourceID = -1;
|
sourceID = -1;
|
||||||
|
|
||||||
@ -129,8 +130,8 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
sampleRate = mc.getCurrentMusicHeader().getSampleRate();
|
sampleRate = mc.getCurrentMusicHeader().getSampleRate();
|
||||||
String millisPerWindowF = df.format(windowSize/(float) sampleRate);
|
String millisPerWindowF = df.format(windowSize/(float) sampleRate);
|
||||||
millisPerWindow = (long) (Float.valueOf(millisPerWindowF)*1000);
|
millisPerWindow = (long) (Float.valueOf(millisPerWindowF)*1000);
|
||||||
|
songChanged = true;
|
||||||
attemptToSync();
|
begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,14 +141,13 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
System.arraycopy(PCM, 1, frequencyBins, 0, frequencyBins.length);
|
System.arraycopy(PCM, 1, frequencyBins, 0, frequencyBins.length);
|
||||||
}
|
}
|
||||||
|
updated = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int freqID = 0; freqID < frequencyBins.length; freqID++) {
|
for (int freqID = 0; freqID < frequencyBins.length; freqID++) {
|
||||||
frequencyBins[freqID] = 0;
|
frequencyBins[freqID] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updated = false;
|
|
||||||
return frequencyBins;
|
return frequencyBins;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,14 +226,14 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mc) {
|
if (o == mc) {
|
||||||
if (arg == mc.states.LOADED) {
|
if (arg == mc.states.LOADED) {
|
||||||
updateMusic();
|
loadMusic();
|
||||||
} else if (arg == mc.states.PLAYING) {
|
} else if (arg == mc.states.PLAYING) {
|
||||||
attemptToSync();
|
begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptToSync() {
|
private void begin() {
|
||||||
if (mc.isPlaying()) {
|
if (mc.isPlaying()) {
|
||||||
if (sourceID == -1) {
|
if (sourceID == -1) {
|
||||||
try {
|
try {
|
||||||
@ -252,4 +252,14 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
public void dispose() {
|
public void dispose() {
|
||||||
streamReadThread.stop();
|
streamReadThread.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAudioChanged() {
|
||||||
|
if (songChanged) {
|
||||||
|
songChanged = false;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,12 @@ import java.util.Observer;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
@ -16,6 +20,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.RhythmBullet;
|
import zero1hd.rhythmbullet.RhythmBullet;
|
||||||
import zero1hd.rhythmbullet.audio.MusicController;
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
@ -24,7 +29,7 @@ import zero1hd.rhythmbullet.audio.visualizer.DoubleHorizontalVisualizer;
|
|||||||
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
|
import zero1hd.rhythmbullet.desktop.audio.PCMObtainer;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.Page;
|
import zero1hd.rhythmbullet.graphics.ui.Page;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.components.MusicControls;
|
import zero1hd.rhythmbullet.graphics.ui.components.MusicControls;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
import zero1hd.rhythmbullet.graphics.ui.components.ScrollingText;
|
||||||
import zero1hd.rhythmbullet.util.ScreenConfiguration;
|
import zero1hd.rhythmbullet.util.ScreenConfiguration;
|
||||||
|
|
||||||
public class MainPage extends Page implements Observer {
|
public class MainPage extends Page implements Observer {
|
||||||
@ -40,10 +45,15 @@ public class MainPage extends Page implements Observer {
|
|||||||
private TextButton quitButton;
|
private TextButton quitButton;
|
||||||
|
|
||||||
private MusicControls musicControls;
|
private MusicControls musicControls;
|
||||||
private ScrollText scrollText;
|
private ScrollingText scrollText;
|
||||||
|
|
||||||
private DoubleHorizontalVisualizer dhv;
|
private DoubleHorizontalVisualizer dhv;
|
||||||
|
|
||||||
|
private boolean playParticles = true;
|
||||||
|
private ParticleEffectPool particlePool;
|
||||||
|
private Array<PooledEffect> particles;
|
||||||
|
private float particleScale;
|
||||||
|
|
||||||
public MainPage(MusicController musicController, AudioMetadataController mmc, AssetManager assetManager, Skin skin, ScreenConfiguration screenConfiguration, ChangeListener playButtonListener, ChangeListener optionsButtonListener) {
|
public MainPage(MusicController musicController, AudioMetadataController mmc, AssetManager assetManager, Skin skin, ScreenConfiguration screenConfiguration, ChangeListener playButtonListener, ChangeListener optionsButtonListener) {
|
||||||
super(0, 0);
|
super(0, 0);
|
||||||
this.mc = musicController;
|
this.mc = musicController;
|
||||||
@ -97,7 +107,7 @@ public class MainPage extends Page implements Observer {
|
|||||||
musicControls.setPosition((getWidth()-musicControls.getWidth() - 15f), 15f);
|
musicControls.setPosition((getWidth()-musicControls.getWidth() - 15f), 15f);
|
||||||
addActor(musicControls);
|
addActor(musicControls);
|
||||||
|
|
||||||
scrollText = new ScrollText("...", "...", skin, false, true);
|
scrollText = new ScrollingText("...", "...", skin, false, true, 1f/screenConfiguration.getTargetFramesPerSecond());
|
||||||
scrollText.setWidth(0.5f*getWidth());
|
scrollText.setWidth(0.5f*getWidth());
|
||||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-30f);
|
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-30f);
|
||||||
addActor(scrollText);
|
addActor(scrollText);
|
||||||
@ -107,6 +117,11 @@ public class MainPage extends Page implements Observer {
|
|||||||
dhv.updateMusic();
|
dhv.updateMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
particles = new Array<>();
|
||||||
|
ParticleEffect particle = assetManager.get("beateffect.p", ParticleEffect.class);
|
||||||
|
particleScale = getWidth()/particle.findEmitter("main").getSpawnWidth().getHighMax();
|
||||||
|
particlePool = new ParticleEffectPool(assetManager.get("beateffect.p", ParticleEffect.class), 0, 16);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,9 +133,40 @@ public class MainPage extends Page implements Observer {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
dhv.draw(batch, parentAlpha);
|
dhv.draw(batch, parentAlpha);
|
||||||
|
updateParticles(batch);
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateParticles(Batch batch) {
|
||||||
|
if (mc.isPlaying() && playParticles) {
|
||||||
|
if (particles.size < 16 && dhv.isSignificantBeat()) {
|
||||||
|
PooledEffect particle = particlePool.obtain();
|
||||||
|
particle.scaleEffect(particleScale);
|
||||||
|
particles.add(particle);
|
||||||
|
}
|
||||||
|
if (particles.size > 0) {
|
||||||
|
for (int i = particles.size - 1; i >= 0; i--) {
|
||||||
|
PooledEffect particle = particles.get(i);
|
||||||
|
particle.draw(batch, Gdx.graphics.getDeltaTime());
|
||||||
|
if (particle.isComplete()) {
|
||||||
|
particles.removeIndex(i);
|
||||||
|
particle.free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopParticles() {
|
||||||
|
playParticles = false;
|
||||||
|
for (int i = particles.size - 1; i >= 0 && particles.size > 0; i--) {
|
||||||
|
particles.get(i).free();
|
||||||
|
particles.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
dhv.dispose();
|
dhv.dispose();
|
||||||
@ -131,6 +177,7 @@ public class MainPage extends Page implements Observer {
|
|||||||
@Override
|
@Override
|
||||||
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
getStage().setScrollFocus(null);
|
getStage().setScrollFocus(null);
|
||||||
|
playParticles = true;
|
||||||
super.setCameraPositionToPage(cameraPosition);
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
creditsPage = new CreditsPage(rhythmBullet.getSkin());
|
creditsPage = new CreditsPage(rhythmBullet.getSkin());
|
||||||
stage.addActor(creditsPage);
|
stage.addActor(creditsPage);
|
||||||
|
|
||||||
musicSelectionPage = new MusicSelectionPage(rhythmBullet.getAssetManager(), rhythmBullet.getSkin(), musicController, musicMetadataController, listeners.returnToMainPageListener, listeners.analysisPageButtonListener);
|
musicSelectionPage = new MusicSelectionPage(rhythmBullet.getAssetManager(), rhythmBullet.getSkin(), musicController, musicMetadataController, rhythmBullet.getScreenConfiguration(), listeners.returnToMainPageListener, listeners.analysisPageButtonListener);
|
||||||
stage.addActor(musicSelectionPage);
|
stage.addActor(musicSelectionPage);
|
||||||
|
|
||||||
analysisPage = new AnalysisPage(musicController, musicMetadataController, rhythmBullet.getSkin(), listeners.musicSelectionPageButtonListener, listeners.confirmedSongListener);
|
analysisPage = new AnalysisPage(musicController, musicMetadataController, rhythmBullet.getSkin(), listeners.musicSelectionPageButtonListener, listeners.confirmedSongListener);
|
||||||
@ -182,6 +182,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
setDisplayedPage(musicSelectionPage);
|
setDisplayedPage(musicSelectionPage);
|
||||||
|
mainPage.stopParticles();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -203,6 +204,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
setDisplayedPage(optionsPage);
|
setDisplayedPage(optionsPage);
|
||||||
|
mainPage.stopParticles();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -224,6 +226,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
setDisplayedPage(creditsPage);
|
setDisplayedPage(creditsPage);
|
||||||
|
mainPage.stopParticles();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ import zero1hd.rhythmbullet.audio.AudioMetadataController;
|
|||||||
import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
|
import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
|
||||||
import zero1hd.rhythmbullet.audio.MusicController;
|
import zero1hd.rhythmbullet.audio.MusicController;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.Page;
|
import zero1hd.rhythmbullet.graphics.ui.Page;
|
||||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
import zero1hd.rhythmbullet.graphics.ui.components.ScrollingText;
|
||||||
|
import zero1hd.rhythmbullet.util.ScreenConfiguration;
|
||||||
|
|
||||||
public class MusicSelectionPage extends Page implements Observer {
|
public class MusicSelectionPage extends Page implements Observer {
|
||||||
Preferences musicFileAnnotation;
|
Preferences musicFileAnnotation;
|
||||||
@ -48,6 +49,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private VerticalGroup vGroup;
|
private VerticalGroup vGroup;
|
||||||
private TextButton back;
|
private TextButton back;
|
||||||
private ScrollPane scrollPane;
|
private ScrollPane scrollPane;
|
||||||
|
private ScreenConfiguration screenConfig;
|
||||||
|
|
||||||
private musicSelectionLoaderThread selectionLoaderThread;
|
private musicSelectionLoaderThread selectionLoaderThread;
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||||
private float musicSelectDelay;
|
private float musicSelectDelay;
|
||||||
|
|
||||||
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, AudioMetadataController musicMetadataController, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, AudioMetadataController musicMetadataController, ScreenConfiguration screenConfiguration, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
||||||
super(1, 0);
|
super(1, 0);
|
||||||
this.assets = assetManager;
|
this.assets = assetManager;
|
||||||
this.mc = musicController;
|
this.mc = musicController;
|
||||||
@ -76,7 +78,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
selectables = new MusicSelectableButtonGroup();
|
selectables = new MusicSelectableButtonGroup();
|
||||||
selectables.setMinCheckCount(0);
|
selectables.setMinCheckCount(0);
|
||||||
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
||||||
|
this.screenConfig = screenConfiguration;
|
||||||
scrollPane = new ScrollPane(vGroup, skin);
|
scrollPane = new ScrollPane(vGroup, skin);
|
||||||
scrollPane.setSize(0.45f*getWidth(), getHeight());
|
scrollPane.setSize(0.45f*getWidth(), getHeight());
|
||||||
scrollPane.setOverscroll(false, false);
|
scrollPane.setOverscroll(false, false);
|
||||||
@ -510,7 +512,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class InformationTable extends Table {
|
private class InformationTable extends Table {
|
||||||
private ScrollText songTitle;
|
private ScrollingText songTitle;
|
||||||
private Label author;
|
private Label author;
|
||||||
private Label musicDuration;
|
private Label musicDuration;
|
||||||
private Label previousTop;
|
private Label previousTop;
|
||||||
@ -525,7 +527,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
setSize(width, height);
|
setSize(width, height);
|
||||||
subInformation = new Table(skin);
|
subInformation = new Table(skin);
|
||||||
albumCover = new Image(assets.get("defaultCover.png", Texture.class));
|
albumCover = new Image(assets.get("defaultCover.png", Texture.class));
|
||||||
songTitle = new ScrollText("", null, skin, true, true);
|
songTitle = new ScrollingText("", null, skin, true, true, 1f/screenConfig.getTargetFramesPerSecond());
|
||||||
author = new Label(null, skin, "sub-font", skin.getColor("default"));
|
author = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||||
musicDuration = new Label(null, skin, "sub-font", skin.getColor("default"));
|
musicDuration = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||||
previousTop = new Label(null, skin, "sub-font", skin.getColor("default"));
|
previousTop = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user