Skip to content

Commit

Permalink
Merge pull request #268 from reco1I/input
Browse files Browse the repository at this point in the history
Run touch input in its own thread to reduce possible delay
  • Loading branch information
Rian8337 authored Aug 14, 2023
2 parents 2e408fd + d7c614c commit 4a4f1ab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/ru/nsu/ccfit/zuev/osu/game/GameScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.SmoothCamera;
import org.anddev.andengine.engine.handler.IUpdateHandler;
import org.anddev.andengine.engine.options.TouchOptions;
import org.anddev.andengine.entity.IEntity;
import org.anddev.andengine.entity.modifier.DelayModifier;
import org.anddev.andengine.entity.modifier.FadeOutModifier;
Expand Down Expand Up @@ -1285,11 +1286,7 @@ else if (stat.getMod().contains(GameMod.MOD_PERFECT)) {
RoomAPI.INSTANCE.notifyBeatmapLoaded();
return;
}

leadOut = 0;
musicStarted = false;
engine.setScene(scene);
scene.registerUpdateHandler(this);
start();
}

// This is used by the multiplayer system, is called once all players in the room completes beatmap loading.
Expand All @@ -1300,6 +1297,12 @@ public void start() {

leadOut = 0;
musicStarted = false;

// Handle input in its own thread
var touchOptions = new TouchOptions();
touchOptions.setRunOnUpdateThread(false);
engine.getTouchController().applyTouchOptions(touchOptions);

engine.setScene(scene);
scene.registerUpdateHandler(this);
}
Expand Down Expand Up @@ -1964,6 +1967,11 @@ public void onModifierFinished(IModifier<IEntity> iModifier, IEntity iEntity) {
engine.setScene(oldScene);
}

// Handle input back in update thread
var touchOptions = new TouchOptions();
touchOptions.setRunOnUpdateThread(true);
engine.getTouchController().applyTouchOptions(touchOptions);

if (storyboardSprite != null) {
storyboardSprite.releaseStoryboard();
storyboardSprite = null;
Expand Down Expand Up @@ -2089,7 +2097,10 @@ private void onExit() {

public void quit() {

//游戏中退出,通过暂停菜单
// Handle input back in update thread
var touchOptions = new TouchOptions();
touchOptions.setRunOnUpdateThread(true);
engine.getTouchController().applyTouchOptions(touchOptions);

if (!replaying) {
EdExtensionHelper.onQuitGame(lastTrack);
Expand Down

0 comments on commit 4a4f1ab

Please sign in to comment.