• Advertisement

Archived

This topic is now archived and is closed to further replies.

Sprite Masking

This topic is 5996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm going a game in 8bit color - on the PalmOS... I'm having a slight problem with sprite masking. Here's what I've done: 1) I've created my sprite - the "visible" part is just a green arrow (For a test) and the rest is white (color index 0) 2) I created a sprite mask - the "visible" part is black (index 255) and the rest is white (color index 0) 3) I've created 3 offscreen surfaces - a back buffer, a buffer for my sprite and a buffer for my mask Now in my game loop I do something like this: -Draw a rectangle of a random color on the entire backbuffer -AND NOT my mask to the back buffer -OR my sprite to the back buffer -copy the backbuffer to the screen From what I've read on the subject of masking this SHOULD work. However my arrow (again, green) changes color (as the background changes color)! The transparency works... but not the color When I AND and OR my mask and sprite the transparency doesn't work and the arrow still changes. AND XORing same results as above. (AND NOT) XORing same result.. ARGH! Thanks! ~Shaun [Edit] - Added what other bit operation trials Edited by - Shaun Patterson on November 20, 2001 9:36:13 PM

Share this post


Link to post
Share on other sites
Advertisement
Raking through my memory I seem to think that there''s an extra step when using a black mask.

Goes something like this:

1) XOR image
2) AND mask
3) XOR image

I think there is a quicker way using a white mask though that only requires two blits?

This will work for you in the meantime anyway.

Share this post


Link to post
Share on other sites
Well I finally got it to work. It turns out the damn resource edtior in Codewarrior for PalmOS set my black pixels to index 215 instead of 255.... I just had to convert the mask to a 1bit image

~shaun

Share this post


Link to post
Share on other sites

  • Advertisement