I notice that SetSpriteVisible() does not affect user interactions with the sprite. If one sprite is on top of another sprite, it always is the one that gets detected via GetSpriteHit() even if it is not visible.
I am curious what methods others have used to make sure that sprites can't interact with anything once they have been set to invisible using SetSpriteVisible(sprNum, 0)? SetSpriteActive() does not help in the situation described above.
Here's a code snippet, the second sprite is always the one detected under the mouse even if it is not visible. Ideally I shouldn't have to move the sprite off-screen or perform other transformations on it just to enable/disable its interactivity when needed.
SetVirtualResolution(1024, 768)
// Create two simple sprites
spr1 = 1 : CreateSprite(spr1, 0)
spr2 = 2 : CreateSprite(spr2, 0)
// Position sprite 1 on screen (small button)
SetSpriteSize(spr1, 128, 128)
SetSpritePosition(spr1, 50, 50)
SetSpriteColor(spr1, 255, 0, 0, 255)
// Position sprite 2 on screen (strech across entire screen)
SetSpriteSize(spr2, GetVirtualWidth(), GetVirtualHeight())
SetSpritePosition(spr2, 0, 0)
SetSpriteColor(spr2, 255, 255, 0, 255)
// Set depth of sprites so that sprite 2 is on top of sprite 1
SetSpriteDepth(spr1, 5)
SetSpriteDepth(spr2, 0)
// Hide sprite 2
SetSpriteVisible(spr2, 0)
SetSpriteActive(spr2, 0)
do
// Show which sprite the mouse is over -- always #2
Print(GetSpriteHit(GetPointerX(), GetPointerY()))
Sync()
loop