a mess
This commit is contained in:
BIN
core/assets/music/editor.mp3
Normal file
BIN
core/assets/music/editor.mp3
Normal file
Binary file not shown.
BIN
core/assets/music/menu.mp3
Normal file
BIN
core/assets/music/menu.mp3
Normal file
Binary file not shown.
Binary file not shown.
@@ -133,6 +133,7 @@ public class Vars{
|
|||||||
public static GlobalData data;
|
public static GlobalData data;
|
||||||
public static EntityCollisions collisions;
|
public static EntityCollisions collisions;
|
||||||
public static DefaultWaves defaultWaves;
|
public static DefaultWaves defaultWaves;
|
||||||
|
public static MusicControl mcont;
|
||||||
|
|
||||||
public static Control control;
|
public static Control control;
|
||||||
public static Logic logic;
|
public static Logic logic;
|
||||||
@@ -208,6 +209,7 @@ public class Vars{
|
|||||||
|
|
||||||
state = new GameState();
|
state = new GameState();
|
||||||
data = new GlobalData();
|
data = new GlobalData();
|
||||||
|
mcont = new MusicControl();
|
||||||
|
|
||||||
mobile = Core.app.getType() == ApplicationType.Android || Core.app.getType() == ApplicationType.iOS || testMobile;
|
mobile = Core.app.getType() == ApplicationType.Android || Core.app.getType() == ApplicationType.iOS || testMobile;
|
||||||
ios = Core.app.getType() == ApplicationType.iOS;
|
ios = Core.app.getType() == ApplicationType.iOS;
|
||||||
|
|||||||
@@ -168,9 +168,6 @@ public class Control implements ApplicationListener{
|
|||||||
Events.on(ZoneConfigureCompleteEvent.class, e -> {
|
Events.on(ZoneConfigureCompleteEvent.class, e -> {
|
||||||
ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave));
|
ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave));
|
||||||
});
|
});
|
||||||
|
|
||||||
Musics.menu.setLooping(true);
|
|
||||||
// Musics.menu.play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createPlayer(){
|
void createPlayer(){
|
||||||
@@ -312,6 +309,19 @@ public class Control implements ApplicationListener{
|
|||||||
//autosave global data if it's modified
|
//autosave global data if it's modified
|
||||||
data.checkSave();
|
data.checkSave();
|
||||||
|
|
||||||
|
if(state.is(State.menu)){
|
||||||
|
if(ui.deploy.isShown()){
|
||||||
|
mcont.silence(); //TODO deploy music
|
||||||
|
}else if(ui.editor.isShown()){
|
||||||
|
mcont.play(Musics.editor);
|
||||||
|
}else{
|
||||||
|
mcont.play(Musics.menu);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//TODO game music
|
||||||
|
mcont.silence();
|
||||||
|
}
|
||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
input.update();
|
input.update();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,39 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
|
import io.anuke.annotations.Annotations.*;
|
||||||
|
import io.anuke.arc.audio.*;
|
||||||
|
import io.anuke.arc.math.*;
|
||||||
|
import io.anuke.arc.util.*;
|
||||||
|
|
||||||
public class MusicControl{
|
public class MusicControl{
|
||||||
|
private static final float finTime = 80f, foutTime = 80f;
|
||||||
|
private @Nullable Music current;
|
||||||
|
|
||||||
|
public void play(@Nullable Music music){
|
||||||
|
if(current == null && music != null){
|
||||||
|
current = music;
|
||||||
|
current.setLooping(true);
|
||||||
|
current.setVolume(0f);
|
||||||
|
current.play();
|
||||||
|
}else if(current == music && music != null){
|
||||||
|
current.setVolume(Mathf.clamp(current.getVolume() + Time.delta()/finTime));
|
||||||
|
}else if(current != null){
|
||||||
|
current.setVolume(Mathf.clamp(current.getVolume() - Time.delta()/foutTime));
|
||||||
|
|
||||||
|
if(current.getVolume() <= 0.01f){
|
||||||
|
current.stop();
|
||||||
|
current = null;
|
||||||
|
if(music != null){
|
||||||
|
current = music;
|
||||||
|
current.setVolume(0f);
|
||||||
|
current.setLooping(true);
|
||||||
|
current.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void silence(){
|
||||||
|
play(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user