Making Hotspots/Objects light up

Started by KorbohneD, Thu 24/11/2016 20:01:06

Previous topic - Next topic

KorbohneD

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


KorbohneD

#2
Well, I am still too stupid for this.

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

        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.

Khris

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

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

KorbohneD

#4
Welp, it works now. Thanks for the help!

Khris


SMF spam blocked by CleanTalk