Hi all! I'm currently working on a game using the C API, working on Windows with the latest SDK version (2.6.2). My game is entirely written in C, so it overrides the update function as outlined in the docs.
I'm trying to use the LCDSprite** playdate->sprite->allOverlappingSprites(int *len)
method to check for collisions in my game, like below:
int numCollisions;
LCDSprite** allCollisions = pd->sprite->allOverlappingSprites(&numCollisions);
// Do collision handling ...
pd->system->realloc(allCollisions, 0);
On my machine, running the above code in the simulator results in the following error being thrown when the first collision occurs:
Exception thrown: read access violation.
L was nullptr.
This happens much lower in the call stack, where L
is a pointer to a lua_State
object, which appears to be uninitialized:
PlaydateSimulator.exe!luaC_newobj(lua_State * L=0x0000000000000000, int tt=5, unsigned __int64 sz=56) Line 259 C
I've tried using some of the other collision checking methods and they all worked OK. There only seems to be a problem with the allOverlappingSprites(...)
method, which I was hoping to use.
What am I doing wrong here? Is there some initialization step I'm missing that might cause this to happen? Any help would be much appreciated, thanks!