Hi, i would be grateful for a solution or some explaining. My example is that i have a controlled spaceship.
here is userinterface:
3 - planet from which is starts, 0.5 and 0.5 the speed of the ship
public void handleBtnLaunchFPSpaceShip() {
this.controller.launchFPSpaceShip(3, 0.5, 0.5);
}
my controller class:
public void launchFPSpaceShip (int id, double dx, double dy) {
PointSimulationElement pls = planetarySystem.getElement(id);
planetarySystem.append(new PlannedSpaceShip(pls.getx(), pls.gety(), dx, dy));
}
So when i click in my applet on the button, it launches. But my question is how to appoint to my spaceship speed, direction etc. I mean before i click launch button, i click on the change speed button which multiplies the 0.5 and 0.5 values and then when i click launch, spaceship is launched with new values.
i have done it with command pattern so far.
controller:
cc is my CommandControl class object.
public void executreCommands(PlannedSpaceShip pse) {
cc.execute();
public void speedFactor(double factor) {
cc.addCommand(new ChangeSpeed(pss, factor));
}
my ChangeSpeed class
public ChangeSpeed(PlannedSpaceShip pps, double factor) {
super();
this.pps = pps;
this.factor = factor;
}
@Override
public void execute() {
//this.pps.speedFactor(factor);
//System.out.println("speed");
System.out.println(factor);
}
aaand how to bind then my command control execution with my created spaceship?
here is my userinterface class method which should do the work, bind executeCommands with my launchFPSpaceShip ?
public void handleBtnLaunchFPSpaceShip() {
this.controller.executeCommands(this.controller.getPSS());
this.controller.launchFPSpaceShip(3, 0.5, 0.5);
}
in controller getPSS method:
public PlannedSpaceShip getPSS() {
return pss;
}
executing commands should work fine, the numbers are printed out in console when i test them.
here is my UI
[img]http://img185.imageshack.us/img185/3876/planetsystem.jpg[/img] blue circle is the moving planet (red ones are the planets, they are separately)
i've googled it, but don't even know exactly what is the topic for that problem? any hint would be appreciated :)