title: LibGDX Box2d associate body with object
body: <p>I'm a beginner Java/LibGDX developer so I'm sorry if I got something terribly wrong here but here's my question: </p>
  
  <p>How could a Box2d body have some object associated with it? </p>
  
  <p>For example a Box2d ball body associated with object that describes how much energy the ball has, what's the charge of the ball, and such. </p>
  
  <p>This might be terribly wrong but here's what I've been trying to do: </p>
  
  <p>I tried to set userdata of the ball to my object like this: </p>
  
  <pre><code>Body.setUserData(MyObject); 
  </code></pre>
  
  <p>and then when I need it, I would retreat it with: </p>
  
  <pre><code>Body.getUserDate();
  </code></pre>
  
  <p>which returns an object and I have no idea what to do with it because I don't know how to access it's fields or methods.. </p>
  
  <p>I hope you understood the question, if not ill try to modify it. </p>
  
  <p>Thank you.</p>