graphical overlay vs surface.DrawImage()

Started by GoodGuy, Mon 13/02/2017 15:51:41

Previous topic - Next topic

GoodGuy

These functions are performed by one and the same. So what's the difference? :P

Crimson Wizard

#1
Overlay.CreateGraphical creates a new visual object that holds some graphic and stays on screen for some time.

DrawingSurface.DrawImage draws image on existing object: room background, existing Overlay (created with CreateGraphical), room object, character frame, GUI, etc.

GoodGuy

Thanks.
Which function (graphical overlay, surface.DrawImage) is faster?
And one more question:
Which textual function (Overlay.CreateTextual, surface.DrawMessageWrapped) is faster?

Crimson Wizard

Quote from: GoodGuy on Mon 13/02/2017 17:44:12
Thanks.
Which function (graphical overlay, surface.DrawImage) is faster?
And one more question:
Which textual function (Overlay.CreateTextual, surface.DrawMessageWrapped) is faster?

These are wrong questions, because these functions do different things, as I tried to explain above.

What are you using them for?

GoodGuy

I understood you) Overlay has a minimum of functions. DrawingSurface and Dynamic Sprite have more opportunities than overlays.
These questions were asked purely out of curiosity (and optimization purposes).

Crimson Wizard

#5
Quote from: GoodGuy on Mon 13/02/2017 17:57:44
I understood you) Overlay has a minimum of functions. DrawingSurface and Dynamic Sprite have more opportunities than overlays.
These questions were asked purely out of curiosity (and optimization purposes).

No, this is really not that. I will try to explain better.

You cannot compare DrawingSurface/DynamicSprites to Overlays, because... they are uncomparable. That is like comparing Color to Line. You do not ask what is better, or faster - Color or Line, right?

Overlay - is an OBJECT, that is positioned on screen, and exists during certain time.
DynamicSprite is an IMAGE, that can be put ON OBJECT.

Graphic Overlays have sprites on them; they may have regular "static" sprites, or dynamic sprites.

In other words, if you create Overlay, there will always be a sprite too.

DynamicSprite, on other hand, can exist on its own, but it cannot be displayed on its own. It must be either assigned to some object, or drawn on object's surface.


EDIT: I somehow suspect, although I am not sure if I am right, that you are trying to draw something on screen, using either Overlay, or DrawingSurface got from Room's background. Is it right?
Because even if that case there is a difference: Overlays are positioned above everything else (room objects and characters), while room background is behind everything else.

GoodGuy

Ah, you are right. These things can't be compared. They have different targets.

Snarky

While it's true that the APIs are not directly comparable, function call by function call, it's also true that there is quite a bit of redundancy between them: I believe every effect you might use Overlays for can also be done using GUIs, DynamicSprites and DrawingSurfaces. (I actually often forget about Overlays, because I've learned how to use the other features, so that's what I always jump to.)

I think there are two cases where you might want to use Overlays:

-When you need to mess with speech display (e.g. for background speech, to have two people talking at the same time, overlapping text, or text effects like using a special font for certain words). The Overlay.CreateTextual allows you to plug into what I assume is the built-in system AGS uses to display speech.

-When you have some graphical effect that sits as a layer on top of the "game world", and that doesn't need to be clickable or affect interaction in any way. It's most useful for static effects, because there's extra work involved in animating it (you need to delete the old overlay and create a new one for each frame). I can't really think of a good example: personally I would always use either a non-clickable Object or a non-clickable GUI with a button, which I'd draw to by assigning it a DynamicSprite and getting its DrawingSurface.

Crimson Wizard

#8
Quote from: Snarky on Mon 13/02/2017 20:35:17
While it's true that the APIs are not directly comparable, function call by function call, it's also true that there is quite a bit of redundancy between them: I believe every effect you might use Overlays for can also be done using GUIs, DynamicSprites and DrawingSurfaces.
Hmm, now that you put it that way, I see what the original question could mean.

Yes, that is actually true, overlays are a bit of redundant thing, because it is almost same thing as GUI, just stripped of many GUI functionality. You may think of overlay as a special GUI surface that is "dynamically created" and "automatically removed by timer", which can only display some stuff but cannot be clicked on.

Regarding optimization, this is a bit complicated. You need to compare two full methods you are using to achieve same thing, taking into account how often and many objects you create, or how often do you redraw, and so on. In some cases difference will be so tiny that not worth thinking about it.

SMF spam blocked by CleanTalk