hey monkey’s,
sorry that I have to ask again, but this problem isn’t solveable for me.
In my case I have some objects. With the help of the wiki and normen I know how to select them, how to animate them and how to control them and stuff like that.
For example i have some Boxes, which consists of a normale jME3.*.Box and my own property’s (i.e. life, rotatingspeed…). Now, I have for exmaple 20 of theses boxes, every box has at the begining 10 life points. When i click on one box the life should decrement (-1). In the case the box is running out of life points these should be removed or something like that. If I click another box the life should be decrement as well. When clicking on a box, which was alerdy one times clicked it should have less lifepoints.
So that is my problem and i dont know how to handle that
My Idea was something like create an object which extends of spatial, but normen told me that this would be the wrong way. I looked in the MonkeyZone but I didn’t find usefull stuff for my situation
Hope, you are able to give me a tipp or something like that
I used custom control as well, but seems that is don’t work
Edit: I dont know how to access the property’s may a little pseudo code example helps to understand what i mean
[java]
class player{
private int life;
public void setlife(int life){…}
public int getLife(){…}
//other stuff
…
}
class Control_Unit extends extends AbstractControl{
public void moveUnit(Vector bla){…} //works great
public decreaseLife(){
//reduce the life of my player
// HERE IS my problem i believe
}
}
MainClass:
private Player test1;
private Player test2;
private Control_Unit mycontrol;
private Control_Unit mycontrol2;
init(){
//construct everything
//add control
test1.addControl(mycontrol);
test2.addControl(mycontrol2);
}
//my acitonlistener
private ActionListener actionListener = new ActionListener() {
if(arguments…){
// fire ray and handle stuff
CollisionResult closest = result.getClosestCollision();
// clicked of an instance of player
// get Controll
mycontrol = new Control_Unit();
mycontrol = closest.getGeometry().getControl(Control_Unit.class);
if(mycontrol == null){
//get it bla bla bla
}
// now i want to reduce the life of these player
con.decreaseLife(); //MAY HERE IS A PROBLEM
}
};
[/java]
In what way’s did it not work ? error log ? are you sure it doesn’t work, or perhaps were you just not using it properly?
Yeah^^
Sorry, please look above there is an pseudo code example
ln:10 public decreaseLife(){
…you dont have a return type there, you need?..
public void decreaseLife(){
Thanks for help, but at the moment my decrease function is empty,
there is my problem. Of course is it void a return nothing
I don’t know how to “build a connection” between the controll and the instance of the player. So that i can say reduce the life of this special unit.
May it could help if you are able to describe with few word how would you solve the problem, cause I believe it isn’t easy to understand what I want, because i wouldn’t understand my own
Here a little summarize of my problem:
i have a few objects consists of various property’s for example lifepoints.
When i click on one of these objects i want to decrease these lifepoints.
Thank you for your help and your endurance
You mean like this?
[java]boxSpatial.setUserData("health", 10);[/java]
when hit:
[java]boxSpatial.setUserData("health", boxSpatial.getUserData("health") - 1);
if(boxSpatial.getUserData("health") <= 0){
boxSpatial.removeFromParent();
}[/java]
This is not exactly black magic…
lol,
it’ damn easy Normen has the force
Why you don’t told me that last time, thank you
Grüße von Berlin nach Bremen^^