I was wondering if there's an interface on the C API for Sprites to add a pointer to a payload somehow. I imagine something like:
void playdate->sprite->setUserData( LCDSprite *sprite, void *payload );
void *playdate->sprite->getUserData( LCDSprite *sprite );
So far I've been using setTag(), and giving it an index into an array of Payload, but obviously this is limited to 256 payloads because the tag-parameter is uint8_t. When the sprite update is called, I can then index-into my the sprite Payload array.
My current use-case is where the Payload structure stores things like an Entity's vital statistics: type, inventory, vim, vigour & muchness. I would like to directly access this structure inside the sprite update-function, where you don't really know which sprite it is... just "one of them".
Maybe there is already a best-case with some other implementation, but if-so, I was unable to find it.
Any thoughts?
thanks.
PS> Obviously the user is responsible for the memory management of the Payloads. If this is undesirable, perhaps a "free()-on-destroy" flag could be added to setUserData().