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

2014/2/11

Can anyone help me i want three objects after three objects move till get to a point they have to stop after each other ??

Gerrit Gerrit

2014/2/11

#
Hello , can anyone help me with this i want those object getting in the world moving three by three in front of each other , if they reached a certain point they must stop three after three after eachother. i tried this but it doesn't work they get on top of each other and in stead of 6 person it becomes three. this is what i got at the moment in my person class in my actor class
 if (getX()== -370 && getY() < 550)
        {
            move(3);
            if (getX() >= 398 && getY() < 450)
            {
                setLocation(398, getY());
            }
        }
        if(getX() == -192 && getY() < 550)
        {
            move(3);
            if (getX() >= 576 && getY() < 450)
            {
                setLocation(576, getY());
            }

        }
Gerrit Gerrit

2014/2/11

#
in my world class i got this
Person one= new Person(counter);
        addObject(one,-370, 320);
       Person two= new Person(counter);
        addObject(two,-370, 357);
        Person three= new Person(counter);
        addObject(three,-370, 395);
        Person four= new Person(counter);
        addObject(four,-192, 320);
      Person five= new Person(counter);
        addObject(five,-192, 357);
       Person six= new Person(counter);
        addObject(six,-192, 395);
danpost danpost

2014/2/11

#
I appears you want all six Person objects to move exactly 768 pixels to the right by making exactly 256 moves of 3 pixels each. Just use an instance int field to count the number of moves made.
You need to login to post a reply.