Box2d objects have a
void* m_userData
field where the user can store data. Typically you store a pointer to another object, for instance a pointer to a sprite that shall be updated with location information every system tick.
I want to store a pointer to another object, but I would be glad if I also could store one extra bit of information. Can I do that in the most significant bit of the pointer? Could the most significant bit of an object pointer be set? I mean the internal memory is only 512 MB (I guess).
Maybe the app be rejected because of this? It’s not completely future proof, and it’s a bit of a hack…
The pointer to ‘another object’ can be whatever you like, so the typical way to do this would be to make a struct/class to hold whatever you want to store in the user data, eg:
Then you would set one of these as the user data…