I use two instances of an actor. The instructor of every instance gets 4 different keynames. The goal is to control each Actor-instance with his own keyset.
But only the first instance reacts to his keyset, the second doesn't!
Why???
Here is the code (only the important snippet):
Thanks for explanation
public class Player extends Actor
{
private Point destination;
private final String rechts, unten, oben, links; // keynames for the directions
private String name; // playername
// Constructor:
public Player(String rechts, String unten, String links, String oben, Point destination, String name,
String filename) {
this.rechts = rechts;
this.unten = unten;
this.links = links;
this.oben = oben;
this.destination = destination;
this.name = name;
this.setImage(filename);
}
public void act()
{
String key = Greenfoot.getKey();
if (key != null) {
if (key.equals(rechts)) {
setRotation(0);
move(1);
}
else if (key.equals(unten)) {
setRotation(90);
move(1);
}
else if (key.equals(links)) {
setRotation(180);
move(1);
}
else if (key.equals(oben)) {
setRotation(270);
move(1);
}
}
}
}



