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

2017/8/18

HEEEEEEEEEEEELP!!!!!!!!

otot otot

2017/8/18

#
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed.
	at greenfoot.Actor.failIfNotInWorld(Actor.java:681)
	at greenfoot.Actor.getOneObjectAtOffset(Actor.java:885)
	at Roboter.act(Roboter.java:39)
	at greenfoot.core.Simulation.actActor(Simulation.java:594)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:552)
	at greenfoot.core.Simulation.runContent(Simulation.java:215)
	at greenfoot.core.Simulation.run(Simulation.java:205)
import greenfoot.*;
import java.awt.Color;
/**
 * Write a description of class Roboter here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Roboter extends Actor
{
    public int mouseX, mouseY;
    
    public int personRotation;
    int angle = getRotation();
    
    
    /**
     * Act - do whatever the Roboter wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        hitRock();
        mouse();
        if(Greenfoot.isKeyDown("W"))
        {
            move(3);
            

        }
        if(Greenfoot.isKeyDown("S"))
        {
            move(-3);
            

        }
    
        Actor mineral;
        mineral = getOneObjectAtOffset (0, 0, Mineral.class);
        if(mineral != null)
        {
           World myWorld = getWorld();
           Surface surface = (Surface)myWorld; 
           Counter counter = surface.getCounter();
           counter.addScore();
           surface.removeObject(mineral);
           return;
        }
       }    public void hitRock()
    {
      {
        Actor rock = getOneIntersectingObject(Rock.class);
        if(rock != null)
        {
            World myWorld = getWorld();
            GameOver gameover = new GameOver();
            myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2);
            myWorld.removeObject(this);
            
        }
      }
    }
    public void mouse()
    {
        if(Greenfoot.getMouseInfo() !=null)
        {
            mouseX = Greenfoot.getMouseInfo().getX();
            mouseY = Greenfoot.getMouseInfo().getY();

            turnTowards(mouseX, mouseY);
            
        }
    }
    
    }


otot otot

2017/8/18

#
pls help me i need to fix this badly
Super_Hippo Super_Hippo

2017/8/18

#
Move line 23 (hitRock method call) to the very end of the act method.
otot otot

2017/8/18

#
THANK YOU SO MUCH.
You need to login to post a reply.