can the transparent color be changed in a Dynamic Sprite?

Started by EnterTheStory (aka tolworthy), Wed 14/04/2010 12:59:16

Previous topic - Next topic

EnterTheStory (aka tolworthy)

I'm shooting irregular holes in my sprites. That is:
1. I use DynamicSprite to get the existing sprite as a mask
2. I draw a rectangle in COLOR_TRANSPARENT
3. the use DrawImage to fill in the rectangle with a nice shaped hole
4. Then use this as a transparency mask

This is fine for single holes, but is no good for overlapping holes because the edges of the hole are added each time.

What I'd really like to do is paste only the hole, then afterwards set the sprite transparent color to the hole color.
or...
just tell AGS to past the hole shape as transparent.
or...
flip the transparent and opaque pixels (using AND, NOT, etc).
Is any of this possible?

Wonkyth

A better way to do this may be to keep the original rectangle that you're using for the hole, and updating it to add more holes, and then use it as a transparency mask on an original copy of the sprite you're sticking the hole in.
"But with a ninja on your face, you live longer!"

EnterTheStory (aka tolworthy)

Quote from: wonkyth on Wed 14/04/2010 14:39:07
A better way to do this may be to keep the original rectangle that you're using for the hole, and updating it to add more holes, and then use it as a transparency mask on an original copy of the sprite you're sticking the hole in.

I've tried that, but it requires multiple deleting of on screen dynamic sprites (e.g. when an on-screen character gets a new hole, their existing dynamic sprite has to be updated). This creates problems with the coordinates bug:

Characters are normally positioned at the bottom middle, but on deleting a dynamic sprite the image stays on screen, but takes on top left coordinates. Meaning the character jumps down and to the right. To overcome this I've been by using replacement cloned characters and trying to the deleting off screen. It makes the code horribly complicated.

Calin Leafshade

why not just draw directly onto the sprite with COLOR_TRANSPARENT?

no need for masks and stuff

EnterTheStory (aka tolworthy)

Quote from: Calin Leafshade on Wed 14/04/2010 16:49:52
why not just draw directly onto the sprite with COLOR_TRANSPARENT?

no need for masks and stuff
You mean make shapes by using lines and rectangles? It might take a while. This is one of my hole masks - it's over six hundred frames long. :) (when you knock a hole in a wall the workers come and build it up again.)


But the good news is that since posting the earlier stuff I gave up with character sprites - the coordinate bug was driving me crazy. Now I use GUIs for any characters that need holes, and everything works perfectly: you can blow any parts of the wall up and it doesn't matter if the holes overlap.

Once the coordinate problem was overcome it was just a matter of copying and drawing the dynamic sprites in the right order.

SMF spam blocked by CleanTalk