Mobile scrolling fix

This commit is contained in:
Anuken
2019-09-15 15:47:42 -04:00
parent f1bf8a0f1a
commit 681347e933
3 changed files with 29 additions and 4 deletions

View File

@@ -134,7 +134,7 @@ public class MusicControl{
/** Plays a music track once and only once. If something is already playing, does nothing.*/
private void playOnce(@NonNull Music music){
if(current != null) return; //do not interrupt already-playing tracks
if(current != null || music == null) return; //do not interrupt already-playing tracks
//save last random track played to prevent duplicates
lastRandomPlayed = music;

View File

@@ -67,7 +67,33 @@ public class MobileInput extends InputHandler implements GestureListener{
public MobileInput(){
Events.on(ClientLoadEvent.class, e -> {
Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
GestureDetector dec = new GestureDetector(20, 0.5f, 0.4f, 0.15f, this){
boolean clearMouse = false;
@Override
public boolean touchDown(int x, int y, int pointer, KeyCode button){
if(Core.scene.hasMouse(x, y)){
clearMouse = true;
return false;
}
return super.touchDown(x, y, pointer, button);
}
@Override
public boolean touchDragged(int x, int y, int pointer){
if(!clearMouse){
return super.touchDragged(x, y, pointer);
}
return false;
}
@Override
public boolean touchUp(int x, int y, int pointer, KeyCode button){
clearMouse = false;
return super.touchUp(x, y, pointer, button);
}
};
Core.input.getInputProcessors().insert(0, dec);
});
}