This site requires JavaScript, please enable it in your browser!
Greenfoot back
ziLaK
ziLaK wrote ...

2015/3/31

I want to remove the object at top of the player

ziLaK ziLaK

2015/3/31

#
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);
        }
    }
}
danpost danpost

2015/3/31

#
The offsets from the center of the player to the top of the head would be (0, -getImage().getHeight()/2).
ziLaK ziLaK

2015/3/31

#
did that but it doesnt remove
ziLaK ziLaK

2015/3/31

#
and doenst play any sound
ziLaK ziLaK

2015/3/31

#
never mind it does work
You need to login to post a reply.