I am finally learning the basics of DrawSuraces etc.
What I have:
- A global dynamicsprite
- A room that refreshes an object in the room using above dynamicsprite
- A function that draws some sprites onto the Dynamicsprite
So far so good, all works fine. However, when I do this:
surface.DrawImage((Xcoord + (41 * whiler)), 58 , frame.Graphic, 0); // Draws a sprite into predermined X coordinate and Y coordinate 58
surface.DrawImage((Xcoord + (41 * whiler)), 68 , frame.Graphic, 90); // Immediately afterwards draws another sprite onto the previous one with 90% transparency
What I expected to see what the first sprite, overlayed by the second one at half transparency. What I got instead, was the first sprite shown correctly and the new sprite drawn over the first one, but instead of appearing as a transparent image, it turns pink!
EDIT / CLARIFICATION: The sprite's transparency works ok for the part that it overlayer the sprite behind it. However, the background sprite onto which all the latter ones are drawn is a 100% transparent .PNG and the parts of the transparent sprite that do NOT overlap with a solid sprite turn pink.
I can see that I am doing something wrong, but I can't tell what. Is it even possible to draw with several transparency values onto a single drawsurface and then stick the result into a DynamicSprite?
Also: basic hints and tips welcome, I have never used any of this stuff before yesterday. :)
Unfortunately, no.
When drawing transparency, in order for AGS to be able to determine the resulting color, the surface pixel can't be "empty".
There's Calin'S AGSBlend plugin which allows combining semi-transparent sprites. Afaik, the only native, background-independent way is to use multiple objects.
I'll take a look at Calin's module to see if I can get it working. I've never used a module before, but I guess this is as good a time to learn as any. :)
Another possible solution is that instead of having the room use a background I simply draw all this stuff into one sprite, that I first draw the background image layers on, then the characters, and finally the overlaying graphics. Not the best solution, but I think I can manage it if all else fails. The question then becomes: how smooth is the framerate with so much "raw-drawing" going on.
Just in case you mistyped, it's a plugin, not a module. But using those isn't harder, just different. Copy the dll into AGS' main folder before opening your game, then activate it in your game.
Regarding FPS, it should take some serious raw drawing before you'll notice a drop. ShiverMeSideways' engine uses extensive raw drawing and collision detection and there wasn't a drop until there were several hundred enemies on the screen at once.
Yeah, that was a typo on my part. But my word still stand, never used plugins before either. :)
Glad to hear FPS shouldn't be an issue, that should open up some new avenues for further developement. I intend to start another miniproject soon and want to experiment with new stuff.
I'll mark this thread as resolved, but will reopen it if I have more questions about Draw functions and the like.