Drawing a sprite and having is disappear again mouse click

Started by Samwise89, Tue 21/06/2011 20:08:33

Previous topic - Next topic

Samwise89

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...

Khris

Are you drawing the image to the background?
Make a backup of the background, then restore it.

Code: ags
// 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.

Dualnames

Code: ags

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;
    }

  } 
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk