Drawingsurface and backgrounds...

Started by De-Communizer, Mon 03/05/2010 14:02:05

Previous topic - Next topic

De-Communizer

The manual doesn't seem to be particularly forthcoming about it (or I'm being dense), but does the drawing surface make things appear underneath or over the top of characters? If I tell it to draw a yellow circle on the screen, is that going to stay there on top of any characters and objects, or does it look like it's just affecting the background? Otherwise, is there any means of just keeping things done on the drawingsurface in the background?

Incidentally, since I'm just starting out with it, are there any decent tutorials for the drawingsurface? Everything I've found so far seems to be obsolete (referring to everything as "rawdraw"), or doesn't answer my questions.

Khris

If you draw on the background, the changes appear underneath characters and objects. To draw above them, use a GUI's background graphic.

There aren't any tutorials I'm aware of but it's not that hard to use the commands.
If you want to manually animate a room's background, the code would look like this:

Code: ags
// top of room script

DrawingSurface*backup;

// inside room_Load

  DrawingSurface*ds = Room.GetDrawingSurfaceForBackground();
  backup = ds.CreateCopy();
  ds.Release();

// inside repeatedly_execute

  DrawingSurface*ds = Room.GetDrawingSurfaceForBackground();
  ds.DrawSurface(backup);  // restore original image

  ds.DrawWhatever();   // draw animation on top

  ds.Release();

De-Communizer

Ah, brilliant - that was exactly what I was lookingf for. Many thanks!

De-Communizer

Ah, one last question on this - you say I need to use a GUI's background graphic for drawing above. Firstly, what would I do to accomplish this rather than drawing on the background?

Secondly, does this mean that things drawn on the GUI background have a position based on the screen, rather than the room?

Calin Leafshade

things drawn to the background are always BEHIND the player, GUIs are on top.

and the answer to question 2 is a simple yes.

De-Communizer

I understand that the things drawn on the background appear under, and things on the GUI appear over, but I'm still unclear as to the means by which I draw on the GUI rather than the background using drawingsurface. Is this akin to using something other than "GetDrawingSurfaceForBackground"?

Khris

You can't directly draw onto a GUI, you need to declare a (global) DynamicSprite, draw to it, then set it as the GUI's .BackgroundGraphic.

SMF spam blocked by CleanTalk