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

2019/1/16

Issue with calling sub-programs from another class

Legitimacy Legitimacy

2019/1/16

#
Hi, my game allows the user to control the bear as they try to eat fish. Here's the code for the collision which shows an error code.
public void checkCollision()
    {
        Actor foodHit = getOneIntersectingObject(bear.class);
        if(foodHit!=null)
        {
            World myWorld = getWorld();
            river river = (river)myWorld;
            counter counter = river.getCounter(); 
            counter.addScore();
            [b]timer timer = (timer)getWorld;[/b]
            timer.addTime();
            myWorld.removeObject(this);
        }
The error code is "Can't find symbol - variable getWorld". I'm aware that the issue lies with the bold line, I don't actually know what it's supposed to do but I remember it was necessary in another game I made. Any help would be greatly appreciated!
Legitimacy Legitimacy

2019/1/16

#
the bolded line didn't work within the code but the line I was pointing out starts with
[b]
and ends with
[/b]
.
You need to login to post a reply.