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

2016/5/9

Update errors in scenario to run in 3.0.3

gmacias gmacias

2016/5/9

#
I wrote this game in version 3.0.1 and would like to know how to update the code to use in 3.0.3. Not sure why it's giving me this error: java.lang.NoSuchMethodError: Mercury.getOneIntersectingObject(Ljava/lang/Class;)Ljava/lang/Object; at Mercury.checkCollision(Mercury.java:60) at Mercury.act(Mercury.java:37) at greenfoot.core.Simulation.actActor(Simulation.java:604) at greenfoot.core.Simulation.runOneLoop(Simulation.java:562) at greenfoot.core.Simulation.runContent(Simulation.java:221) at greenfoot.core.Simulation.run(Simulation.java:211)
    /**
     * This method checks to see if Mercury is colliding with a cloud. 
     * If he is, then he will fall from the sky and lose his wings. 
     */
    private void checkCollision() 
    {
        Cloud cloud = (Cloud) getOneIntersectingObject(Cloud.class);
        if (cloud != null) 
        {
            World world = getWorld();
            Actor mercury = (Actor) world.getObjects(Mercury.class).get(0);
            cloud.setImage("largewings.png");
            cloud.setLocation(getX(), getY());
            Greenfoot.playSound("ohno.wav");
            getWorld().removeObject(this);

            
        }
    }
gmacias gmacias

2016/5/9

#
Never mind! I figured out that I had two different variables in two different classes with the same name. Changing the name of one variable fixed the error.
You need to login to post a reply.