you mean in the same way that flash works?

(after 5 seconds of thought)

You need to make extra parts of your sprite transparent.

You can't directly I think,
one way to do it would be to create a temporary surface and blit your sprite to it.
Then blit the masked area to the temporary sprite (the masked area would be your normal transparent colour and another colour set as the transparent colour for this blit operation..)

so in effect, you are drawing extra transparent areas onto your sprite so when you blit this new surface to the screen, part of it is obscured.

Does this make sense?


For an example, you have a pre-rendered background with some nice chainlink fencing in the foreground.. but of course, there's all part of the background image so in order to walk behind them, you have to make a mask.

So you create another image with the foreground elements rendered in your normal sprite's background colour and the background elements rendered in another colour (possibly black) This image would only have 2 colours in it.

You blit your sprite image to a temporary surface
Then blit the part of the mask image to the temporary surface to add additional transparency to your sprite.
Then you blit your sprite to the screen and he'll be behind the chain link fence, but in front of the background elements.

Of course, this idea would work best with alpha transparency because with a simple transparent colour approach, you get very hard, jaggy edges.

Does this help?