visualizer improvements

This commit is contained in:
Harrison Deng 2017-09-15 01:06:12 -05:00
parent 4ba2deb8da
commit 33c9eeef2f
4 changed files with 19 additions and 90 deletions

View File

@ -100,10 +100,10 @@ public class BasicVisualizer extends VisualizerCore {
public void updatePositionInfo() {
int barSpace;
angleRad.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
for (int i = 0; i < bars.length; i++) {
barSpace = i*(barWidth+spaceBetweenBars);
bars[i].rotate(rotation);
bars[i].setRotation(rotation);
bars[i].setPosition(xPos + barSpace*angleRad.x, yPos + barSpace*angleRad.y);
}
}
@ -120,30 +120,6 @@ public class BasicVisualizer extends VisualizerCore {
}
}
@Override
public void setHeight(int height) {
updatePositionInfo();
super.setHeight(height);
}
@Override
public void setWidth(int width) {
updatePositionInfo();
super.setWidth(width);
}
@Override
public void setxPos(int xPos) {
updatePositionInfo();
super.setxPos(xPos);
}
@Override
public void setyPos(int yPos) {
updatePositionInfo();
super.setyPos(yPos);
}
public void setRotation(float rotation) {
this.rotation = rotation;
}

View File

@ -10,8 +10,8 @@ public class VisualizerCore implements Disposable {
protected MusicManager mm;
private FloatFFT_1D fft;
float[] audioPCM;
protected int width, height;
protected int xPos, yPos;
protected float width, height;
protected float xPos, yPos;
protected int barCount;
public VisualizerCore(int width, int height, int x, int y) {
@ -46,19 +46,19 @@ public class VisualizerCore implements Disposable {
public void dispose() {
}
public void setxPos(int xPos) {
public void setxPos(float xPos) {
this.xPos = xPos;
}
public void setyPos(int yPos) {
public void setyPos(float yPos) {
this.yPos = yPos;
}
public void setWidth(int width) {
public void setWidth(float width) {
this.width = width;
}
public void setHeight(int height) {
public void setHeight(float height) {
this.height = height;
}

View File

@ -27,6 +27,12 @@ public class Visualizer extends Widget {
@Override
public void act(float delta) {
vis.setHeight(getHeight());
vis.setWidth(getWidth());
vis.setxPos(getX());
vis.setyPos(getY());
vis.setRotation(getRotation());
vis.updatePositionInfo();
vis.calculate();
super.act(delta);
}
@ -36,63 +42,6 @@ public class Visualizer extends Widget {
vis.setMM(mdp);
}
@Override
public void setX(float x) {
coords.set(getX(), getY());
getStage().stageToScreenCoordinates(coords);
vis.setxPos((int) coords.x);
super.setX(x);
}
@Override
public void setY(float y) {
coords.set(getX(), getY());
getStage().stageToScreenCoordinates(coords);
vis.setyPos((int) coords.y);
super.setY(y);
}
@Override
public void setWidth(float width) {
size.set(getWidth(), getHeight());
getStage().stageToScreenCoordinates(size);
vis.setWidth((int) size.x);
super.setWidth(width);
}
@Override
public void setHeight(float height) {
size.set(getWidth(), getHeight());
getStage().stageToScreenCoordinates(size);
vis.setWidth((int) size.y);
super.setHeight(height);
}
@Override
public void setSize(float width, float height) {
setHeight(height);
setWidth(width);
}
@Override
public void setPosition(float x, float y) {
setX(x);
setY(y);
super.setPosition(x, y);
}
@Override
public void setRotation(float degrees) {
vis.setRotation(degrees);
super.setRotation(degrees);
}
@Override
public void layout() {
vis.updatePositionInfo();
super.layout();
}
@Override
public void setColor(Color color) {
vis.setColor(color);

View File

@ -17,7 +17,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.SongListController;
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
import zero1hd.rhythmbullet.events.OnDifferentSongListener;
import zero1hd.rhythmbullet.screens.PreGameScreen;
import zero1hd.rhythmbullet.ui.components.Visualizer;
@ -123,6 +122,11 @@ public class MainPage extends Page implements OnDifferentSongListener {
// end play button
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);