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

2012/1/24

Moving in formation

Mikeson Mikeson

2012/1/24

#
Hi Im working on a game that requires flying in formation so far I have it so they bounce at sides of the world this works good except the Objects "all of the same class" overlap as they bounce of the wall to change direction. I would like to set up a spacing between the objects. so when the first to bounce bounces and so do the rest at the same time. I looking at using geetIntersectingObjects thou I think getNeighbours may be more suitable. But Im not sure how to wode the code correctly.
mjrb4 mjrb4

2012/1/24

#
The easiest way to do this would be to have a static (boolean) variable in the class which you set to change when an object hits the side of the world. Being static it belongs to the class not instances of the class, so as soon as one instance changes it the rest will see the updated value and can respond accordingly.
You need to login to post a reply.