I'm doing a fairly simple piece of drawing:
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.Clear();
surface.DrawingColor = 63;
surface.DrawLine(mouse.x, 0, mouse.x, 600);
surface.DrawLine(0, mouse.y, 800, mouse.y);
surface.DrawingColor = 0;
surface.DrawCircle(CharX,CharY,8);
surface.Release();
But for some reason it clears pink, not transparent.
I've tried using COLOR_TRANSPARENT, but it makes not difference.
Any Ideas?
What is the color depth of your game?
Also, try .Clear(0);
The pink color (RGB value (255, 0, 255) also known as "magic pink") is transparent when used on sprites. However, you're drawing it to the background which doesn't support transparency - because there's nothing behind it to show through - so this is expected behavior.
If you want to display the lines and the circle on uniformly colored background, Clear it to whatever color you want it to show. If, however you want the room's background image to show behind the them, don't use the Clear command at all. Instead (assuming you've previously drew to the background and need to undo those changes before drawing updated position of lines/circle), restore a copy of the original DrawingSurface - created using DrawingSurface.CreateCopy() in the EnterRoomBeforeFadein event for instance - with the DrawingSurface.DrawSurface() function.
Look up DrawingSurface.CreateCopy() in the manual for an example of this.
My colour depth is 16-bit so that wouldn't affect it.
As far as using DrawingSurface.CreateCopy() goes, I don't think it will work for what I'm trying to achieve.
Looks like I'll just have to clear to a solid clour. :'(
Well, it would help if you told us what you ARE trying to achieve ;)
Well if you want the pink areas to be transparent then are you wanting it to show the previous background through the transparent areas or just solid black? For the first route just leave out the Clear altogether. Otherwise just do Clear(0). As you've been told.
As far as DrawingSurface.CreateCopy:
// top of script
DrawingSurface *backgroundCopy;
// inside drawing function
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
if (backgroundCopy == null) backgroundCopy = surface.CreateCopy(); // first time, create back-up copy of background
else surface.DrawSurface(backgroundCopy); // restore previous background
surface.DrawingColor = 63;
surface.DrawLine(mouse.x, 0, mouse.x, 600);
surface.DrawLine(0, mouse.y, 800, mouse.y);
surface.DrawingColor = 0;
surface.DrawCircle(CharX, CharY, 8);
surface.Release();
// inside your save, load, quit, etc. functions
backgroundCopy.Release(); // free the memory, we won't need it where we're going
That would work for the "show the previous background prior to any drawing" method...
I tried just leaving out the surface.Clear() altogether, but as I'm drawing every frame the screen quickly gets covered with unwanted lines.
I'll give that other code a try....
Yep, it worked.
Thanks.
Most of my problems revolve around not understanding how to use certain commands.
Once I understand how they work, I can do anything... ;D
Well DrawingSurface.CreateCopy does exactly as it says. It creates a copy of an existing drawing surface. The idea of the above code is that before you do any of the drawing business you're going to get a raw copy of the room's background and hold onto that. You draw onto the actual room background to produce your desired effect. Then the next loop before you draw the effect again, you reset the background by restoring the original background image by drawing our copy on top of the current background.
Make sense?
In any case glad you got it sorted!
h, the code makes perfect sense, I just didn't know how to implement the .Clear() command.
I could have done a few tests to determine how it works but it would be fiddly.
Thanks.