I'm attempting to create a simple class that loads a model from the enum however when i call it in the main class all three models load at once.
A later goal is to clone each model from the first time the method is called so theirs a reference to each in memory since their would be more than one instance of that character at a time. Is this actually what I want it to do I'm unsure??
package com.tps1.GameState;
import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;
import com.jmex.game.StandardGame;
import com.jmex.game.state.GameState;
import com.jmex.game.state.GameStateManager;
import com.tps1.GameState.SkyBoxManager.SkyBoxGameState;
public class Charactertype extends playerGameState {
public static enum type {
AVENGER("ninja"),
SENTINAL("robot"),
PHANTOM("fish");
private type(String theName)
{
Charactertype.init(theName);
GameState Charactertype = new Charactertype(theName);
GameStateManager.getInstance().attachChild(Charactertype);
Charactertype.setActive(true);
}
public void build()
{
Charactertype.get();
}
}
private static Logger logger = Logger.getLogger(Charactertype.class.getName());
// the one and only instance of the Charactertype class
private static Charactertype instance = null;
// this string finds the model and loads it
private String strType=null;
// init must be called once when the game starts
// after that the Charactertype can be accessed from everywhere with
// Charactertype.get()
public static void init(String characterType) {
instance = new Charactertype(characterType);
}
public static Charactertype get() {
if (instance == null) {
// init has not been called yet.
logger.severe("ALERT, call init first!!");
}
return instance;
}
// the constructor is private, it can only be called inside this class
private Charactertype(String type){
super(type);
this.strType = type;
setupCharacter();
}
private void setupCharacter(){
}
// return the character name type
public String getCharactertype() {
return strType;
}
public static void main(String[] args) throws InterruptedException, ExecutionException {
StandardGame standardGame = new StandardGame("GameControl", StandardGame.GameType.GRAPHICAL, null);
standardGame.start();
try {
SkyBoxGameState.Manager().setActive(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
type.AVENGER.build();
//type.SENTINAL.get();
//type.PHANTOM.get();
}
}