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

2018/6/7

Getting the error "java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: (file)

Lev Lev

2018/6/7

#
Hi, I'm almost done this maze game for my final computers project, and I'm making and have encountered an error that I cannot fix at all. java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: RogueUpA It's something to do with an image file called "RogueUpA", and I've tried everything I could to fix it, and It's due tomorrow. Please help... Here is the code for my Rogue:
 public class Rogue extends Animal
{
    
    private int rotateLeft, rotateRight, rotateUp, rotateDown;
    
    private GreenfootImage image1 = new GreenfootImage("RogueUpA");           
    private GreenfootImage image2 = new GreenfootImage("RogueLeftA");
    private GreenfootImage image3 = new GreenfootImage("RogueRightA"); 
    private GreenfootImage image4 = new GreenfootImage("RogueSmallA"); 

       
    public void act()
    {            
        movement();
        checkObstacle();
        fire();
       
        rotateRight = 0;
        rotateLeft = 180;
        rotateUp = 270;
        rotateDown = 90;
    }

    public void movement()
    {       
        Actor wall = getOneIntersectingObject(Wall.class);
        Bullet bullet1 = new Bullet();

                if(Greenfoot.isKeyDown("up"))
        {
                        setImage(image1);
            setRotation(270);
            move(1);

            if(canSee(Wall.class))
            {
                move(-1);
            }
        }
        if(Greenfoot.isKeyDown("down"))
        {
                       setImage(image2);
                       
            setRotation(90);
            move(1);

            if(canSee(Wall.class))
            {
                move(-1);
            }
        }
        if(Greenfoot.isKeyDown("left"))
        {
                       setImage(image3);
                       
            setRotation(180);
            move(1);

            if(canSee(Wall.class))
            {
                move(-1);
            }
        }
        if(Greenfoot.isKeyDown("right"))
        {
                       setImage(image4);
            setRotation(0);
            move(1);

            if(canSee(Wall.class))
            {
                move(-1);
            }
        }      
    }

    public void checkObstacle()
    {
      
                if(canSee(Leviathan.class))
        {
            Greenfoot.setWorld(new Loser());
        }
                if(canSee(Enemy.class))
        {
            Greenfoot.setWorld(new Loser());
        }
    }

    private void fire() {
        Bullet bullet1 = new Bullet(); 

        if ("space".equals(Greenfoot.getKey()))
        {
            getWorld().addObject(bullet1, getX(),getY()); 
            bullet1.setRotation(getRotation());
        }
    }
}
danpost danpost

2018/6/7

#
Lev wrote...
I'm making and have encountered an error that I cannot fix at all. java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: RogueUpA
The file names are missing their extensions (".jpg", ".png", or ".gif").
You need to login to post a reply.