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

2018/5/4

my loop stopped working?!

Dustin.Ross Dustin.Ross

2018/5/4

#
I had a loop that populated my enemies and was trying some things with it decided to go back and now it's not working
    /**
     * populates enemys in corners of the world
     */
    private void populateEnemy()
    {
       Enemy myEnemy = new Enemy();
       for (int x=0; x < enemyCount; x++)
           {
               addObject(myEnemy, 0,0);
               addObject(myEnemy, 0,yDimention);
               addObject(myEnemy, xDimention,0);
               addObject(myEnemy, xDimention,yDimention);
            }
    }
jamesN616 jamesN616

2018/5/5

#
Specify what you mean by trying some things. Do you call populateEnemy() once in world, or is it called by actors, etc? If populateEnemy() can't be reached through act() then your loop won't be able to repeat itself.
danpost danpost

2018/5/5

#
You have to create a new Enemy() for each enemy you wish to place into your world.
You need to login to post a reply.