Im using a singleton for a player character and want to know if i can do different methods for checking the singleton instance
public class Player extends Entity{
keyHandeler key;
private static Player instance = null;
public static Player getInstance(Panel pnl, keyHandeler key){
if(instance == null){
instance = new Player(pnl,key);
}
return instance;
}
public static Player getInstance(Panel pnl){
if(instance == null){
instance = new Player(pnl);
}
return instance;
}
private Player(Panel pnl, keyHandeler key) {
super(pnl);
this.key = key;
solidArea = new Rectangle();
solidArea.x = 8;
solidArea.y = 16;
solidAreaDefaultX= solidArea.x;
solidAreaDefaultY = solidArea.y;
solidArea.width = 32;
solidArea.height = 32;
setDefaultValues();
getPlayerImage();
}
private Player(Panel pnl) {
super(pnl);
} ```