questions about "Fishies" example code.

I’m having trouble figuring out exactly what’s going on in part of the code.

When the fish are created, something like this happens:

for i=1,numFish do  
 local group = display.newGroup()  
 -- code  
 group.x = nx  
 group.y = ny  
 -- code  
 doAnimate[#doAnimate + 1] = group   
 group:addEventListener( "touch", touchFish )  
end  

First, why is it creating a new display group for each fish? Or is it?

Why not an image object instead of a group? Does it have something to do with code I’m not listing above, i.e. the fact that fish can be flipped?

If I had a bunch of objects to animate, but each had only one form, is this the appropriate method to use, or is there a better way?

I just don’t understand why it’s a display group.

Sean. [import]uid: 4993 topic_id: 634 reply_id: 300634[/import]

Hello Sean,

Your suggestion that it has to do with the fact that the fish can flip from orange to purple and back is correct. Both images (orange and purple) are added to the group so that they move as one and you only have to deal with one thing (the group) and not two (the two images).

If you have a bunch of objects to animate and they only have one form, you could simply manipulate the image objects instead of groups.

Arjan
[import]uid: 4824 topic_id: 634 reply_id: 1252[/import]

Would it not be better to use sprites rather than groups in this instance? [import]uid: 5354 topic_id: 634 reply_id: 1279[/import]