I need to be able to add actors while the world is running. I'm attempting to do this by taking a combination of key presses to trigger a method, and then taking user info on an item ID, and how many of the items that the user wants, and then adding that number of that actor into the world.
Ex. - However, this still only adds a single actor. What am I doing wrong/missing?
public void act() {
if (Greenfoot.isKeyDown("shift") && Greenfoot.isKeyDown("w")) {
addMiscActor();
}
}
public String actorID;
public String howManyActors;
public int numberOfActors;
public void addMiscActor() {
actorID = JOptionPane.showInputDialog("Actor ID");
howManyActors = JOptionPane.showInputDialog("How many actors?");
numberOfActors = Integer.parseInt(howManyActors);
if (actorID == "M1") {
for (int i=0; i<numberOfActors; i++) {
addObject(new ActorOne(), 35, 35);
}
}
}

