سؤال

I need to set the gravity in a box2d world right in the center of the canvas. This means that objects will fall in the center of the canvas.

The box2d framework is the javascript framework.

Thank you.

هل كانت مفيدة؟

المحلول

Gravity is not a location, it's a direction. To do what you want, you can set gravity to zero and apply a small force to all bodies every timestep, toward the location you want them to move to.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top