Book Image

Learning LibGDX Game Development- Second Edition

Book Image

Learning LibGDX Game Development- Second Edition

Overview of this book

Table of Contents (21 chapters)
Learning LibGDX Game Development Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Building the Options window


Make the following changes in MenuScreen to add the Options window layer:

import com.packtpub.libgdx.canyonbunny.util.CharacterSkin;
import com.packtpub.libgdx.canyonbunny.util.GamePreferences;

private Skin skinLibgdx;

private void loadSettings() {
  GamePreferences prefs = GamePreferences.instance;
  prefs.load();
  chkSound.setChecked(prefs.sound);
  sldSound.setValue(prefs.volSound);
  chkMusic.setChecked(prefs.music);
  sldMusic.setValue(prefs.volMusic);
  selCharSkin.setSelectedIndex(prefs.charSkin);
  onCharSkinSelected(prefs.charSkin);
  chkShowFpsCounter.setChecked(prefs.showFpsCounter);
}

private void saveSettings() {
  GamePreferences prefs = GamePreferences.instance;
  prefs.sound = chkSound.isChecked();
  prefs.volSound = sldSound.getValue();
  prefs.music = chkMusic.isChecked();
  prefs.volMusic = sldMusic.getValue();
  prefs.charSkin = selCharSkin.getSelectedIndex();
  prefs.showFpsCounter = chkShowFpsCounter.isChecked();
  prefs.save();
}

private...