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

2013/10/29

Strange error

Lee1121 Lee1121

2013/10/29

#
Hello, I've got a funny problem, which I have no idea how to fix (project link down below). Whenever I get close to the object enemy, I will get the error saying that the enemy object isn't there when I call getX(); Do any of you have an idea how to fix this problem? Thanks in advance, Lee My project
Zamoht Zamoht

2013/10/29

#
Change the following methods in the Player class.
    public void getEnemy()
    {
        turn++;
        List <Enemy> allEnemy = getObjectsInRange(64*3, Enemy.class);
        
        for (Enemy enemy : allEnemy)
        {
            moveEnemy(enemy);
        }
    }
    
    public void moveEnemy(Enemy enemy)
    {
        enemy.checkPlayer();
    }
Lee1121 Lee1121

2013/10/29

#
Zamoht wrote...
Change the following methods in the Player class.
    public void getEnemy()
    {
        turn++;
        List <Enemy> allEnemy = getObjectsInRange(64*3, Enemy.class);
        
        for (Enemy enemy : allEnemy)
        {
            moveEnemy(enemy);
        }
    }
    
    public void moveEnemy(Enemy enemy)
    {
        enemy.checkPlayer();
    }
Wow that was quick, thank you very much!
You need to login to post a reply.