Hi all,
Currently I am implementing a space shooter which has a ship that moves when the mouse moves, and a chase camera behind the ship.
However, I am using a gamecontroller with custom controllers attached to a ship node as such:
private void initInput(){
manager = new GameControlManager();
GameControl rollLeft = manager.addControl("Roll Left");
rollLeft.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_X, false));
GameControl rollRight = manager.addControl("Roll Right");
rollRight.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_X, true));
GameControl rollUp = manager.addControl("Roll Up");
rollUp.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_Y, false));
GameControl rollDown = manager.addControl("Roll Down");
rollDown.addBinding(new MouseAxisBinding(MouseAxisBinding.AXIS_Y, true));
/* assign Controls to the rotation Controller */
RotationController rollControl = new RotationController(player, rollRight,
rollLeft, 30f, Axis.Y);
RotationController upDownControl = new RotationController(player, rollUp,
rollDown, 30f, Axis.X);
GameControl accelerate = manager.addControl("Accelerate");
accelerate.addBinding(new KeyboardBinding(KeyInput.KEY_W));
ActionController acc = new ActionController(accelerate,new AccelerateAction(this.player));
GameControl brake = manager.addControl("Brake");
brake.addBinding(new KeyboardBinding(KeyInput.KEY_S));
ActionController br = new ActionController(brake,new BrakeAction(this.player));
GameControl fire = manager.addControl("Fire");
fire.addBinding(new MouseButtonBinding(MouseButtonBinding.LEFT_BUTTON));
ActionController f = new ActionController(fire, new FireAction(this.player.getWeapon()));
player.addController(rollControl);
player.addController(upDownControl);
player.addController(acc);
player.addController(br);
player.addController(f);
am = new AbsoluteMouse("my mouse", display.getWidth(), display.getHeight());
am.setRenderState(TextureLoader.LoadTextureState("file:/c:/crosshair.png"));
am.setLocalTranslation(new Vector3f(display.getWidth() / 2, display.getHeight() / 2, 0));
root.attachChild(am);
}
At the end of this code I also want to initalize an absolutemouse, so I have control over the mouse pointer. I want the mouse pointer to have a crosshair as the cursor and whenever I move this mouse this cursor moves around the screen and the ship follows this cursor. Just like with games like wing commander and such. However, in this implementation the cursor simply sits at the center of the screen and whenever I move the mouse the ship seems to follow the mouse but the cursor still sits in the center.
I think I am doing something wrong, should I assign all controllers to the absolutemouse and let the model follow this via the update sequence of the code?
Regards,
Frank