So, I set the bars up to my liking, including a player 1 and player 2 bars both having 10,10 health. When a player presses the Space bar button a missile is created, or the num0 key a player two missile is created. These missiles fly forward until colliding with the edge of the map or with the other player. On collision with another player or edge the missile is removed. how do I make it so when the missile collides with player one health is taken off the health bar?
and this is the collision part of the rocket
//This is in my world public health1 bar = new health1("Player 1", "Health Points", 10, 10); //Along with this in the constructor of the world addObject (bar, 115, 25);
{ move(-5); Actor collided = getOneObjectAtOffset(-40, 0, Player1.class); if(collided != null) { //The line where I expect the health subration to go? getWorld().removeObject(this); } }