Best way to show hotspots in realtime? [Solved]

Started by BrightBulb, Wed 14/03/2012 15:15:40

Previous topic - Next topic

BrightBulb

Hi everybody,

I wanted to facilitate gameplay by marking all hotspots & objects of a room with a red cross (for example) when pressing a certain key. Now I am aware of some script by Proskrito, but I wanted it to be in real time with the possibility to be turned on all the time without having to press a key.

The only solution I've come up so far is to create objects (as a red cross) to place over all the hotspots & objects. But with the object limit in rooms this doesn't seem very practicable.

Is there perhaps another solution?

Thanks

Khris

What I would do is use a GUI with a background image that's dynamically drawn.
That way there's no limit to how many crosses you can put on top of the scene.

-In the EntersRoomBeforeFadein event, determine the center location of all hotspots
-upon activation of the feature, in repeatedly_execute, convert object, character and hotspot positions to screen coordinates and draw them on a cleared DynamicSprite, then set it as the GUI's background image.
-to turn off the feature, simply turn off the GUI. (The GUI is set to not-clickable, that way it won't interfere with the gameplay in any way, clicks "go through" it.)

The great thing about using a GUI for this is that you can either put the crosses above everything else, including GUIs, or "between" a static GUI and the room itself, which could look pretty good.

(I took a look at my own module and it uses a horribly convoluted way of doing this: first, it takes a screenshot, then turns off all characters and objects, then draws the crosses on top of the screenshot and sets that as background. I don't know why the hell I did it that way, maybe I'm missing something now and there was a good reason though.)

BrightBulb

Thanks for the really quick answer. I currently trying to implement it, but it won't work.

I have following script:

function DrawHotspot(){
       DynamicSprite *sprite = DynamicSprite.CreateFromExistingSprite(395); //395 = just a transparent sprite   
       DrawingSurface *surface = sprite.GetDrawingSurface();
     
     /*
    here come a whole bunch of loops to locate hotspots etc.
    within the loops a use the surface.DrawImage command to draw images of red crosses
    */


    gHotspotmarker.BackgroundGraphic=sprite.Graphic;
    spritenumber = sprite.Graphic;
    surface.Release();
    sprite.Delete();
}

The problem is that sprite.Graphic is empty (blue cup). The whole thing works if I use

DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();

instead of the sprite as drawing surface. Of course, then I can't deactivate the cross markers by disabling the GUI.

Any help?



Khris

Two issues:

1. You don't need an empty sprite, you can create an empty DynamicSprite. Just call DrawingSurface.Clear() to make it transparent (but that may not be necessary).

2. Not only is sprite a local variable which is destroyed at the end of the function, you're deleting the sprite from memory yourself!
The graphical content doesn't get copied to the GUI background, what you're actually doing is telling AGS to use the sprite when it's time to draw the GUI's background.
So it needs to be kept in memory. Just move the very first line above the function and don't delete the sprite at the end.

BrightBulb

Yep deleting the sprite I wanted to use wasn't that fortunate.

But with your help it works perfectly now. ;D

Thank you very much.


SMF spam blocked by CleanTalk