Im trying to remove a object when he touch the Player head, but it doesnt work. My code for it :
public void act()
{
moveLeft();
moveRight();
apanharObjt();
}
public void maisScore(int pontos)
{
score = score + pontos;
}
public void apanharObjt()
{
Actor maca = getOneObjectAtOffset(getImage().getWidth()/2, getImage().getHeight(),Maça.class);
if(maca != null)
{
Greenfoot.playSound("bite.mp3");
getWorld().removeObject(maca);
maisScore(5);
}
}
}