Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: KorbohneD on Thu 24/11/2016 20:01:06

Title: Making Hotspots/Objects light up
Post by: KorbohneD on Thu 24/11/2016 20:01:06
Hello,

this is my first post in the forum.
I am currently making the test game for my real project and I came upon one problem.
When you press spacebar, there should be some kind of indication for hotspots/objects/charakters.
Like some glowing orb that indicates where to click to prevent pixel hunting.
First I thought about doing a seperate Character with a sprite overlay that I premake, but if the player takes a object, the indication will still be there.
Next envisioned another object view with the overlay to the objectsprite, that i enable when I press spacebar, but the update-function is in the global script so I can't access roomobjects, can I?

Is there any way to do this?

Liebe GrüàŸe,
KorbohneD
Title: Re: Making Hotspots/Objects light up
Post by: Khris on Thu 24/11/2016 20:25:55
Here's how to do this: http://www.adventuregamestudio.co.uk/forums/index.php?topic=45567.msg611800#msg611800
Title: Re: Making Hotspots/Objects light up
Post by: KorbohneD on Thu 24/11/2016 21:14:24
Well, I am still too stupid for this.

I now have these pieces of code in my on-key-press function:
Code (ags) Select

        DynamicSprite *sprite = DynamicSprite.Create(320, 200, true);
        DrawingSurface *surface = sprite.GetDrawingSurface();
        surface.Clear();
        surface.DrawImage(100, 100, 145);
       
        gHotspotmarker.BackgroundGraphic = sprite.Graphic;


I only draw one sprite now, but instead of it showing on a clear plane, i just get the white Gui when i press the button.
Title: Re: Making Hotspots/Objects light up
Post by: Khris on Thu 24/11/2016 21:57:21
As I explained in the other thread, the declaration of the sprite cannot be inside a function, or the sprite is deleted as soon as the function finishes.

// the following above on_key_press
DynamicSprite *sprite;

function ShowHotspots() {
  int w = System.ViewportWidth;
  int h = System.ViewportHeight;
  if (sprite == null) sprite = DynamicSprite.Create(w, h, true);
  DrawingSurface *surface = sprite.GetDrawingSurface();
  surface.Clear();
  surface.DrawImage(100, 100, 145);
  surface.Release();
  gHotspotmarker.SetSize(w, h);
  gHotspotmarker.BackgroundGraphic = sprite.Graphic;
  gHotspotmarker.Visible = true;
}

  // in on_key_press
  if (k == eKeySpace) ShowHotspots();


Also make sure your GUI's background and border color is set to 0 in the editor.
Title: Re: Making Hotspots/Objects light up
Post by: KorbohneD on Thu 24/11/2016 22:09:34
Welp, it works now. Thanks for the help!
Title: Re: Making Hotspots/Objects light up
Post by: Khris on Thu 24/11/2016 23:34:06
Kein Thema :)