Hello every one another post will be here for our android 2D car game
tutorial series, this will be the tutorial number 9 of my video, with in
this class we will meet a new class called "Enum" Type to give you the
exact definition of enum class you can read it from java documentation,
The enum type! especially in libgdx are use to enumerate a sequence of
methods or constant that we are going to define later on, but for this
game we use it for defining list of difficulty in our game,since we will
not make an instance of this class from other classes but instead we
will access it by defining methods that will return's value of our that we
define as "easy","medium", "hard" this attributes has individual method
that will return the primitive type that is float and contains different
value. this boolean method's will be called later on whenever we set
level's in GameManager Class which is responsible for saving the game
States of our game.
package settings;
import config.GameConfig;
public enum DifficultyLevel {
easy(GameConfig.DIFFICULTY_EASY),
medium(GameConfig.DIFFICULTY_MEDIUM),
hard(GameConfig.DIFFICULTY_HARD);
private float difficultySpeed;
private DifficultyLevel(float difficultySpeed) {
this.difficultySpeed = difficultySpeed;
}
public boolean isEasy(){
return this == easy;
}
public boolean isMedium(){
return this == medium;
}
public boolean isHard(){
return this == hard;
}
public float getDifficultySpeed() {
return difficultySpeed;
}
}
0 Comments