0
\$\begingroup\$

I have a simple game with a platform (a ground that's not infinitely long). During the game I have about 10-30 balls on average that'll fall off the platform. There's gravity so I think they'll keep falling until the end of the game. My question is should I put a function that check if position within boundary in the render() function, render() function is called in every frame. Or should I leave those balls falling. And let box2d keep on calculating their speed and velocity etc?

So basically I'm wondering which cost less, checking every body's position or calculating dropping object's velocity and position. I think they happen with same frequency, once per frame.

Or is this trivial for 10-30 balls and I can ignore it?

\$\endgroup\$
1
\$\begingroup\$

if you never spawn new bodies above those 30 it probably won't matter letting them fall. Otoh it's trivial to delete them, and the check to do so needn't run every frame. Besides 30 iterations is nothing, even on mobile.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.