Is there an reason to that you put all the screen touch events inside the loop that gets the cordinates for the screen touch?
I experimented a little bit with the main menue screen button press loop! And got an more responsive menue with this!
- Code: Select all
@Override
public void update(float deltaTime) {
List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
game.getInput().getKeyEvents();
Boolean TouchScreen=false;
int len = touchEvents.size();
for(int i = 0; i < len; i++) {
TouchEvent event = touchEvents.get(i);
if(event.type == TouchEvent.TOUCH_UP) {
touchPoint.set(event.x, event.y);
guiCam.touchToWorld(touchPoint);
TouchScreen=true;
break;
}
}
if(TouchScreen==true){
if(OverlapTester.pointInRectangle(playBounds, touchPoint)) {
Assets.playSound(Assets.clickSound);
game.setScreen(new GameScreen(game));
return;
}
if(OverlapTester.pointInRectangle(highscoresBounds, touchPoint)) {
Assets.playSound(Assets.clickSound);
game.setScreen(new HighscoresScreen(game));
return;
}
if(OverlapTester.pointInRectangle(helpBounds, touchPoint)) {
Assets.playSound(Assets.clickSound);
game.setScreen(new HelpScreen(game));
return;
}
if(OverlapTester.pointInRectangle(soundBounds, touchPoint)) {
Assets.playSound(Assets.clickSound);
Settings.soundEnabled = !Settings.soundEnabled;
if(Settings.soundEnabled)
Assets.music.play();
else
Assets.music.pause();
}
if(OverlapTester.pointInRectangle(ExitBounds, touchPoint))
QuitGame=true;
}
if(QuitGame==true)
ExitGame();
}
As you can see so did i keep an minimal amount of code inside the touch event loop.
Its size is decided by how big the screen size is?
I know its nothing in an basic game like this but should save a few fps ingame?
Or are i completely wrong?
I want some answers from my android guru
Iam thinking of putting all the overlap test calls in an private void and only calling them when someone actually presses the screen
