Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Samwise89 on Tue 21/06/2011 20:08:33

Title: Drawing a sprite and having is disappear again mouse click
Post by: Samwise89 on Tue 21/06/2011 20:08:33
HI, i am trying to to get an image to display when a hotspot is clicked which is working fine, but i want it to disappear again on another click of the mouse like when a Display string does.

I am using the DrawingSurface DrawImage function...
Title: Re: Drawing a sprite and having is disappear again mouse click
Post by: Khris on Tue 21/06/2011 20:51:02
Are you drawing the image to the background?
Make a backup of the background, then restore it.

// top of room script

DynamicSprite*backup;

  // before drawing the image:
  backup = DynamicSprite.CreateFromBackground();


Then just draw backup to the background after the click.

There are other ways to temporarily display an image though, it depends on whether you want the image to appear on top of characters/objects or below them.
Check out Overlay.CreateGraphical (http://www.adventuregamestudio.co.uk/manual/Overlay.CreateGraphical.htm).
Title: Re: Drawing a sprite and having is disappear again mouse click
Post by: Dualnames on Tue 21/06/2011 20:51:18

Variables:
  Hotspot*check;
  DrawingSurface *surface,backup;
  bool drawn;


function on_mouse_click (MouseButton button)
{
  if (button==eMouseLeft)
  {
check=Hotspot.GetAtScreen(mouse.x,mouse.y);

    if (check==null || check.ID==0 || drawn) {
    surface.DrawSurface(backup);
    backup.Release();
    surface.Release();
    drawn=false;
    }

    else
    {
    surface = Room.GetDrawingSurfaceForBackground();
    backup = thesurfaceyourealreadydrawingtogoeshere.CreateCopy();
    surface.DrawImage(bla bla bla whatever you have already)
    drawn=true;
    }

  }
}