Need help - detect when a container is full

Hi,

Is there a way to detect if a container is full. I am looking to create a game that drops object into a container and I need to detect that the playing container is full which signals game over. I cannot use counting nor just measuring height (the objects are not squared or rectangle) because they do not stack up straight (physics is used)

Any help is very much appreciated.

Thank you [import]uid: 71789 topic_id: 12540 reply_id: 312540[/import]

http://mobile.tutsplus.com/tutorials/corona/corona-sdk_game-development_basketball/

In the basketball game they use some code to detect when the ball goes through the hoop, it might be helpful to notice when something is full, good luck. [import]uid: 71568 topic_id: 12540 reply_id: 45820[/import]

Could you figure out the fill line Y coordinate, then as things come to a rest you can just check if they are above the fill line height? You wouldn’t get a hit until things stacked up high enough and if they were above the fill line it must be full?
–Croisened [import]uid: 48203 topic_id: 12540 reply_id: 45823[/import]

Thanks for the replies.

@croisened, is there a way to detect the rest state? Is it possible to detect that a body stops moving?
If i can do that then that solves my problem. Thanks. [import]uid: 71789 topic_id: 12540 reply_id: 45831[/import]

To detect if the object is moving, you can do, if object.y is less than 200 for example, than it wold be full, but to make sure that only counts from the rising direction and not from a falling direction, you should put a timer on the function to wait a certain time after the object has fallen.

To detect if the object has stopped moving, make variables and get the current coordinates of the object, as currX and currY. Every second or so, using an event listener, reset the currX and currY values. Using the difference between the new and old, once the difference reaches 0, it would have stopped moving.

Sorry this is just the logic, but I don’t have the time right now to write the code out for you. [import]uid: 7116 topic_id: 12540 reply_id: 45840[/import]

Thank you all for the suggestions.

Here is the solution that worked for me.

I drew an invisible top border slightly higher than the fill line of the container. When that top border detects a collision, I assume the container is full. [import]uid: 71789 topic_id: 12540 reply_id: 45842[/import]