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

2016/10/26

adding multiple actors using one constructor.

Shadow7 Shadow7

2016/10/26

#
this is kind of hard to word so just bear with me. I am trying to add lets say 7 actors. but being lazy I want to make or a Method that will add the 7. here is what I have so far
MyWorld(){
// size of world blah blah.

Rope R= new Rope();
this.addObject(R, this.getwidth(), this.getHeight();

}
so instead of having to make 7 new rope's is there a way or could I make a Method that i could call and it would make 7 ropes and also line the ropes up side by side?
Super_Hippo Super_Hippo

2016/10/26

#
Is this what you want?
for (int i=0; i<7; i++)
{
   addObject(new Rope(), 100+i*30, 100);
}
You need to login to post a reply.