ok…
[lua]function bounceAnimation:enterFrame( event )[/lua]
is a table function. [lua]bounceAnimation[/lua] is the table. [lua]self[/lua] refers to bounceAnimation, because it is the table that the function is being called on. “enterFrame” is a built-in event. this function definition therefore makes the bounceAnimation table respond to the enterFrame events
so [lua] for i,v in ipairs( self ) do[/lua] means go through each of the indexed items in the bounceAnimation table (indexed from 1 to #bounceAnimation… 1,2,3 etc like an array)
we know from the previous question that these items in the array contain “group” which is the display group for each fish, containing it’s 2 different images (orange fish and blue fish)
from the [lua]ipairs[/lua] statement, [lua]i[/lua] is the index (1,2,3) and [lua]v[/lua] is the value at [lua]bounceAnimation[i][/lua] which is the fish “group”
and this statement:[lua]Runtime:addEventListener( “enterFrame”, bounceAnimation );[/lua]
means on every enterFrame event (30 or 60 times a second), call the bounceAnimation function. except in our case bounceAnimation isn’t a function, it is a table. therefore it means call the bounceAnimation:enterFrame function. (which you saw we defined above)
[import]uid: 6645 topic_id: 7900 reply_id: 28154[/import]