TEST SCREEN
There is no test screen or test code that I have done for SettingsManager of MTX, because it is straightforward enough, however I will talk about what can you do with it, It will make your life easier and faster by writing less and less code.
SETTING MANAGER
Setting manager will give you bunch of static methods and variables that you can use in every game lets see, what are these. All methods are documented, so you can read if you do not understand.
Set as a first launch and check if it is first launch
You may need to create initial files or settings in the first launch of the game and check if it is the first launch or not in every game launch, methods below works with android preferences, and sets the game as first launch, and checks it if you need. You can use theses methods in create() method of the game to set some stuff
There is no test screen or test code that I have done for SettingsManager of MTX, because it is straightforward enough, however I will talk about what can you do with it, It will make your life easier and faster by writing less and less code.
SETTING MANAGER
Setting manager will give you bunch of static methods and variables that you can use in every game lets see, what are these. All methods are documented, so you can read if you do not understand.
Set as a first launch and check if it is first launch
You may need to create initial files or settings in the first launch of the game and check if it is the first launch or not in every game launch, methods below works with android preferences, and sets the game as first launch, and checks it if you need. You can use theses methods in create() method of the game to set some stuff
if(SettingsManager.isFirstLaunch()){
SettingsManager.setFirstLaunchDone(true);
// DO SOMETHING FOR FIRST LAUNCH
// Create database
// Create textfiles
// Set initial settings
// etc..
} else {
// IT IS NOT FIRST LAUNCH
// Load previous settings
// Set some stuff
// etc..
}
Create text files in local storage
If I dont do big games (multiplayer rpgs or similar), I like to use text files for storing basic game data, best place to create thiese data is the LOCAL STORAGE
Read / Write / Changes existing line in text files
You may need to read, write new line or change existing line in text files. In Android text files could be in INTERNAL STORAGE (cant write or cahnge anything here, only read), LOCAL STORAGE and EXTERNAL STORAGE. (These are the FileTypes)
Number of lines and Comma Seperated Values in text files
You may need the number of lines in a text file or your text file lines can be comma separated values such as (Jack,24,Engineer) in a single line, my method returns a ArrayList for each value between commas.
Music, SoundFX, Vibration and Previous settings retrieving for each game launch
You can set music, soundFX and vibration settings and quickly access in every class of the game with static variables also with a single method you can retrieve all the settings from android preferences in every game launch.
Here is a example for sound effects, setSound(), use this in your settings screen or anywhere in the game, it is static method.
If I dont do big games (multiplayer rpgs or similar), I like to use text files for storing basic game data, best place to create thiese data is the LOCAL STORAGE
SettingsManager.createTextFileInLocalStorage(String fileName)
Read / Write / Changes existing line in text files
You may need to read, write new line or change existing line in text files. In Android text files could be in INTERNAL STORAGE (cant write or cahnge anything here, only read), LOCAL STORAGE and EXTERNAL STORAGE. (These are the FileTypes)
SettingsManager.readLine(String strFile, int lineNumber, FileType fileType)
SettingsManager.writeLine(String strFile, String newValue, FileType fileType)
SettingsManager.writeExistingLine(String strFile, int lineNumber, String newValue, FileType fileType)
Number of lines and Comma Seperated Values in text files
You may need the number of lines in a text file or your text file lines can be comma separated values such as (Jack,24,Engineer) in a single line, my method returns a ArrayList for each value between commas.
SettingsManager.getNumberOflInesInTextFile(String strFile, FileType fileType)
SettingsManager.getValuesSeperatedByCommaInLine(String strFile, int lineNumber, FileType fileType)
Music, SoundFX, Vibration and Previous settings retrieving for each game launch
You can set music, soundFX and vibration settings and quickly access in every class of the game with static variables also with a single method you can retrieve all the settings from android preferences in every game launch.
Here is a example for sound effects, setSound(), use this in your settings screen or anywhere in the game, it is static method.
// Set sound condition (Android Pref), also sets the static variable isSoundOn;
SettingsManager.setSound(boolean isSoundActive);
// Get sound condition, static variables (We do not retrieve from android pref ea// ch time we need, performance costs)
SettingsManager.isSoundOn;
// Use this in game launchs, it sets music, soundFX and vibration settings from preferences
SettingsManager.setGeneralSettings();
0 yorum:
Yorum Gönder