我想使用特定的代碼,但它不會出於某種原因。我必須在同一個類中的方法:Java使用代碼的方法不起作用
public void InputEnter()
{
if(Input.GetKey(getCoords)) {
Move(GetTransform().GetPos());
System.out.println((GetTransform().GetPos()));
}
}
這種方法讓我Vector3f的一些座標,一旦我回車。其他代碼寫入文件。
public void ProcessText()
{
System.out.println("ProcessText Operational");
String file_name = "C:/Users/Server/Desktop/textText.txt";
try
{
ProcessCoords file = new ProcessCoords(file_name);
String[] aryLines = file.OpenFile();
int i;
for (i = 0; i < aryLines.length; i++)
{
System.out.println(aryLines[i]);
if(aryLines[i].startsWith("makeGrass:")) {
String Arguments = aryLines[i].substring(aryLines[i].indexOf(":")+1, aryLines[i].length());
String[] ArgArray = Arguments.split(",");
this.makeGrass(Double.parseDouble(ArgArray[0]),
Double.parseDouble(ArgArray[1]),
Double.parseDouble(ArgArray[2]));
}
}
ProcessCoords data = new ProcessCoords(file_name);
data.writeToFile("makeGrass:");
System.out.println("Coordinates Saved!");
} catch(IOException e) {
System.out.println(e.getMessage());
}
}
我想要做的是使用InputEnter方法在ProcessText方法,所以我剛剛刪除InputEnter並在ProcessText方法所使用的輸入代碼:
public void ProcessText()
{
System.out.println("ProcessText Operational");
String file_name = "C:/Users/Server/Desktop/textText.txt";
try
{
ProcessCoords file = new ProcessCoords(file_name);
String[] aryLines = file.OpenFile();
int i;
for (i = 0; i < aryLines.length; i++)
{
System.out.println(aryLines[i]);
if(aryLines[i].startsWith("makeGrass:")) {
String Arguments = aryLines[i].substring(aryLines[i].indexOf(":")+1, aryLines[i].length());
String[] ArgArray = Arguments.split(",");
this.makeGrass(Double.parseDouble(ArgArray[0]),
Double.parseDouble(ArgArray[1]),
Double.parseDouble(ArgArray[2]));
}
}
if(Input.GetKey(getCoords)) {
Move(GetTransform().GetPos());
ProcessCoords data = new ProcessCoords(file_name);
data.writeToFile("makeGrass:");
System.out.println("pressing enter doesn't work!!");
System.out.println((GetTransform().GetPos()));
}
System.out.println("Input.GetKey doesn't work anymore, but why and how to fix it??");
} catch(IOException e) {
System.out.println(e.getMessage());
}
}
但是現在,按enter做不再給我以前的座標,我真的不明白爲什麼,我需要一些幫助。
非常感謝!