Hi everyone,
I’m trying to set up some code that toggles a ‘build mode’ in my game (similar to that in an RTS game). I have a Boolean value which I toggle, then its true, the build mode is active, when false, it isnt.
When it is active, I want a template of the object to follow the mouse position so the player can choose where to place it, then place it with a mouse click.
I’ve got the Boolean value to toggle with a keypress, but my mouseclick wont work, it doesnt give any error messages, it just doesnt do anything. I’m sure its probably something simple but I’ve been stuck for a while on this.
Here is my code:
[java]
}//end of simple init app
private void initKeys(){
inputManager.addMapping("mineBM", new KeyTrigger(KeyInput.KEY_NUMPAD0));
inputManager.addMapping("mClickLM", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "mineBM");
inputManager.addListener(analogListener, "mclickLM");
}//init keys end
private ActionListener actionListener = new ActionListener(){
public void onAction(String name, boolean keyPressed, float tpf){
if (name.equals("mineBM") &&!keyPressed){
mineBM = !mineBM;
System.out.println(mineBM);
}//end of keypress
}//end of on action
};//end of actionlistener
private AnalogListener analogListener = new AnalogListener(){
public void onAnalog(String name, float intensity, float tpf){
if (name.equals("mclickLM")){
if (mineBM=true){
System.out.println("click!!");
}
}//end of mouseclick (leftbutton)
}//end of analog
};//end of analoglistener
}//end of simpleApplication
[/java]
Thanks a lot for any help