You can implement the following behavior using the position of your main sprite as a target for friends sprite. This will include performing separation (maintaining a minimum distance), traction (maintaining a maximum distance), and weakening (to make the movement smooth).
Exact algorithms (and some others) are described in detail in Craig Reynolds' remarkable animation work . There is also a video with separate functions and sample source code (in C ++).
The algorithm you need (this is a combination of a few simpler ones), Leader following
EDIT : I found two simple implementations of the algorithms mentioned in the article, with visible source code here and here . You will need to recombine them a bit from the runoff (which is mainly after the centroid) in order to follow one leader. The language is Processing, resembling a java-like pseudo-code, so I hope that understanding should not be a problem. C ++ source code . I mentioned earlier, can also be downloaded, but clearly does not contain a leader.
I do not know about any cocos2d implementations.
source share