Advertisement
dermetfan

How to set userData with the Box2DMapObjectParser

Oct 13th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. /* In the properties of an object in the Tiled editor, you can use Aliases#userData.
  2.  * for example:
  3.  * userData: some string
  4.  * or like this:
  5.  * userData: 1
  6.  *
  7.  * If you create the map programmatically you can set any Objects like e.g. a Sprite as user data of course. */
  8.  
  9. // Then the user data will be where you put it in.
  10. Body body = parser.getBodies().get("some body");
  11. Object userData = body.getUserData();
  12.  
  13. // The same works for fixtures and joints.
  14. Fixture fixture = parser.getFixtures().get("some fixture");
  15. Object userData = fixture.getUserData()
  16.  
  17. Joint joint = parser.getJoints().get("some joint");
  18. Object userData = joint.getUserData();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement