If you think the Android project X3n0break listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.x3n0m0rph59.breakout;
//www.java2s.comimport com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
publicclass SettingsInputProcessor implements InputProcessor {
@Override
publicboolean keyDown(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean touchDown(int screenX, int screenY, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean touchUp(int screenX, int screenY, int pointer, int button) {
final Camera camera = ((SettingsScreen) ((App) Gdx.app.getApplicationListener()).getCurrentScreen()).getCamera();
finalfloat mX = camera.unproject(new Vector3(screenX, screenY, 0.0f)).x;
finalfloat mY = camera.unproject(new Vector3(screenX, screenY, 0.0f)).y;
final Rectangle hotRectToggleSound = new Rectangle(0, 200, (float) Gdx.graphics.getWidth(), 200);
final Rectangle hotRectToggleMusic = new Rectangle(0, 400, (float) Gdx.graphics.getWidth(), 200);
final Rectangle hotRectOKBack = new Rectangle(1700, 900, (float) Gdx.graphics.getWidth(), 200);
if (hotRectToggleSound.contains(new Vector2(mX, mY))) {
Config.getInstance().setSoundMuted(!Config.getInstance().isSoundMuted());
final Preferences prefs = Gdx.app.getPreferences(Config.APP_NAME);
prefs.putBoolean("soundMuted", Config.getInstance().isSoundMuted());
return true;
}
if (hotRectToggleMusic.contains(new Vector2(mX, mY))) {
Config.getInstance().setMusicMuted(!Config.getInstance().isMusicMuted());
final Preferences prefs = Gdx.app.getPreferences(Config.APP_NAME);
prefs.putBoolean("musicMuted", Config.getInstance().isMusicMuted());
SoundLayer.playMusic(Musics.BACKGROUND);
return true;
}
if (hotRectOKBack.contains(new Vector2(mX, mY))) {
ScreenManager.getInstance().showScreen(ScreenType.MENU);
return true;
}
return false;
}
@Override
publicboolean touchDragged(int screenX, int screenY, int pointer) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean mouseMoved(int screenX, int screenY) {
// TODO Auto-generated method stub
return false;
}
@Override
publicboolean scrolled(int amount) {
// TODO Auto-generated method stub
return false;
}
}