Android Open Source - catchanimals Controller Option






From Project

Back to project page catchanimals.

License

The source code is released under:

GNU General Public License

If you think the Android project catchanimals 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 com.ricardorb.controllers;
/* ww  w . j  ava  2s .  c o m*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.audio.Sound;

public class ControllerOption {
  
  private static boolean barFinger;
  private static boolean musicOn;
  private static boolean effectsOn;
  private static Preferences prefs;
  
  
  public static void load(){
    
    prefs = Gdx.app.getPreferences("options");
    
    if(!prefs.getBoolean("notFirstTime")){
      setBarFinger(false);
      setEffectsOn(true);
      setMusicOn(true);
      setNotFirstTime(true);
    }
    
    barFinger = prefs.getBoolean("barFinger");
    musicOn = prefs.getBoolean("musicOn");
    effectsOn = prefs.getBoolean("effectsOn");
  }
  

  public static boolean isBarFinger() {
    return barFinger;
  }


  public static void setBarFinger(boolean barFinger) {
    ControllerOption.barFinger = barFinger;
    prefs.putBoolean("barFinger", barFinger);
    prefs.flush();
  }


  public static boolean isMusicOn() {
    return musicOn;
  }


  public static void setMusicOn(boolean musicOn) {
    ControllerOption.musicOn = musicOn;
    prefs.putBoolean("musicOn", musicOn);
    prefs.flush();
  }


  public static boolean isEffectsOn() {
    return effectsOn;
  }


  public static void setEffectsOn(boolean effectsOn) {
    ControllerOption.effectsOn = effectsOn;
    prefs.putBoolean("effectsOn", effectsOn);
    prefs.flush();
  }
  
  public static void setNotFirstTime(boolean notFirstTime) {
    prefs.putBoolean("notFirstTime", notFirstTime);
    prefs.flush();
  }
  
  public static void playSound(Sound sound){
    if(isEffectsOn()){
      sound.play();
    }
  }
  
}




Java Source Code List

com.ricardorb.catchanimals.Assets.java
com.ricardorb.catchanimals.CatchAnimals.java
com.ricardorb.catchanimals.android.AndroidLauncher.java
com.ricardorb.catchanimals.desktop.DesktopLauncher.java
com.ricardorb.controllers.ControllerBasket.java
com.ricardorb.controllers.ControllerOption.java
com.ricardorb.inputs.InputBasket.java
com.ricardorb.screens.GameScreen.java
com.ricardorb.screens.MainMenuScreen.java
com.ricardorb.screens.OptionScreen.java
com.ricardorb.sprites.Animal.java
com.ricardorb.sprites.Basket.java
com.ricardorb.sprites.Element.java