Closed OFmarting closed 8 years ago
Hey there, you should be able to use getPhysics().findBodyById(R.id.yourviewid)
on the PhysicsLayout. Have you given this a try?
Unfortunately the Body is null when I try to access it after adding the View with addView().
Hey there, this has to do with the fact that the body is not actually created until the view measures itself. This is due to the fact that we need to wait for measure before adding the bodies so that we have the proper size to set the bodies to. A OnBodyCreatedListener
has been added to the 2.1.0 release so that you can hook into the body creation and do the connections as needed.
Thank You!
No problem! Let me know if it works out
Everything worked out well :+1:
Hi, I'm adding Views to the PhysicsLayout with addView(). I want to create a Joint between multiple dynamically added Views. How can I access the Body Instance right after adding the View so I can create a Joint?