SDK version: 3.1.2
I am encountering a sporadic bug in my game where the collision response function of a sprite is called with another sprite that has collisions disabled.
Here is the situation:
LCDSprite *sprite_a = pd->sprite->newSprite();
LCDSprite *sprite_b = pd->sprite->newSprite();
pd->sprite->setCollisionsEnabled(sprite_a, true);
pd->sprite->setCollisionsResponseFunction(sprite_a, my_collision_response);
pd->sprite->setCollisionsEnabled(sprite_b, false);
And, under some circumstances (which are still unclear to me), this happens:
SpriteCollisionResponse my_collision_response(LCDSprite *sprite, LCDSprite *other)
{
assert(pd->sprite->collisionsEnabled(sprite));
// XXX: this next line sometimes asserts!
assert(pd->sprite->collisionsEnabled(other));
}
The SDK docs for playdate->sprite->setCollisionsEnabled say:
Set the collisionsEnabled flag of the given sprite (along with the collideRect, this determines whether the sprite participates in collisions). One is true, 0 is false. Set to 1 by default.
So I would expect that both asserts never trip. Is this a bug in the SDK or am I misinterpreting the sprite API functionality?