How to count the number of objects of a certain type that are on screen

If I have spawned a number of items (rocks, for example) is there a way to get a count of how many of them are currently in the scene?

I guess I could keep track of this manually but I’m wondering if the game engine does this already… [import]uid: 8353 topic_id: 2113 reply_id: 302113[/import]

If you add them to a table, or if they are in a group where they are the only type of object in that group/table, you can use group.numChildren or #table to know how many they are.
I do not think the game engine keeps track of it. [import]uid: 8486 topic_id: 2113 reply_id: 6308[/import]

The Box2D engine can count ALL bodies (*) in the world, but it doesn’t classify them in the way suggested above. That’s more of a game-state issue that should happen in your game logic.

(*) We haven’t exposed this API currently, since it seems like more of a “middleware/integration” feature – we use it internally when tying Box2D to Corona. [import]uid: 3007 topic_id: 2113 reply_id: 6399[/import]