So here is the code in my Hero class. (I want to be able to change the value of jumpHeight when the Hero walks into a specific object)
And this is my Object class:
How can I make sure that when my Hero touches the object, his jump height increases?
public class Hero extends AnimatedActor
{
private int vSpeed = 0;
private int acceleration = 2;
public int jumpHeight = -20; // how high to jump
//I want to be able to change the value of jumpHeight when the Hero walks into a specific object
public int getjumpHeight()
{
return jumpHeight;
}
public class Object extends Mover
{
public void act()
{
move();
//In this class I want the jumpHeight to change when the Hero touches the object
//How do I now retrieve the value of jumpHeight from the Hero class ?
getjumpHeight();
Actor hero = getOneIntersectingObject(Hero.class); //I also don't know what to do with this
if (hero != null)
{
jumpHeight = jumpHeight + 10;
world.removeObject(this);
}
}
}
