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

2022/10/31

trying to eat with the whole charectar

RHMU RHMU

2022/10/31

#
I am trying to eat a actor but it is only eating when the cookie is being eating by the 'granny' but only when it passes through the middle. this is the code i have been using and i am not sure how to fix it
public void eat()
    {
        Actor coookie;
        coookie = getOneObjectAtOffset(0, 0, coookie.class);
        if (coookie !=null)
        {
            World world;
            world = getWorld();
            world.removeObject(coookie);
        }
    }
Super_Hippo Super_Hippo

2022/11/1

#
You could use
if (isTouching(coookie.class))
{
    removeTouching(coookie.class));
}
danpost danpost

2022/11/2

#
Or, change line 4 to:
cookie = getOneIntersectingObject(cookie.class);
RHMU RHMU

2022/11/11

#
thank so much :)
You need to login to post a reply.