Hallo 😀
Ich bin ein Noob was Java betrifft, möchte es aber lernen.
Hier ein kleines Problem:
wie kann ich zwei Methoden ("run" und "run2") im selben Moment laufen lasse, ohne das die eine nicht läuft?
So 😉
Das ist der code und ich möchte nur wissen was ich machen kann, damit "run" und "run2" gleichzeitig laufen, ohne das die eine nicht arbeitet 🙂
Danke im vorraus
MFG
Momo
Ich bin ein Noob was Java betrifft, möchte es aber lernen.
Hier ein kleines Problem:
wie kann ich zwei Methoden ("run" und "run2") im selben Moment laufen lasse, ohne das die eine nicht läuft?
Java:
doAll();
}
public static void doAll(){
run2();
run();
}
public static void run(){
int x = (int) b.hPosition();
int z = 2;
int q = 2;
int y = (int) b.vPosition();
while (true){
x=x+z;
y=y+q;
move (x,y);
Hilfe.pause(10);
if (fenster.hPosition ()== b.hPosition()-1280)
z= -2;
if (fenster.vPosition()==b.vPosition()-620)
q = -2;
if (fenster.hPosition()==b.hPosition())
z= 2;
if (fenster.vPosition()==b.vPosition())
q= 2;
}
}
public static void run2(){
int x1= (int) b2.hPosition();
int z1 = 2;
int q1 = 2;
int y1 = (int) b2.vPosition();
while (true){
x1=x1+z1;
y1=y1+q1;
move2 (x1,y1);
Hilfe.pause(10);
if (fenster.hPosition ()== b2.hPosition()-1280)
z1= -2;
if (fenster.vPosition()==b2.vPosition()-620)
q1 = -2;
if (fenster.hPosition()==b2.hPosition())
z1= 2;
if (fenster.vPosition()==b2.vPosition())
q1= 2;
}
}
public static void move (int x, int y){
b.setzePosition(x, y);
}
public static void move2 (int x1, int y1){
b2.setzePosition(x1, y1);
}
}
So 😉
Das ist der code und ich möchte nur wissen was ich machen kann, damit "run" und "run2" gleichzeitig laufen, ohne das die eine nicht arbeitet 🙂
Danke im vorraus
MFG
Momo
Zuletzt bearbeitet: