A_Overlay

From ZDoom Wiki
Jump to navigation Jump to search


Actor

bool A_Overlay(int layer, statelabel start = null, bool nooverride = false)

Usage

This function is a considerably expanded version of A_GunFlash, allowing users to create multi-layer weapon animations.

Note, although this functions is defined in Actor, its behavior is tied to the PSprite class. As such, it can only be utilized in those classes that have access to PSprite and can create new instances of it, which includes PlayerPawn and classes based on StateProvider: Weapon and CustomInventory. In case of StateProvider, this function can only be called in states that are already being drawn with the help of a PSprite, i.e. the states that are designed to draw sprites on the screen (so, for example, you can use it in the weapon's Ready/Fire/Hold and similar states, but not its Spawn states).

Regular actors, Inventory items and such can NOT utilize overlays or PSprite in any way.

Calling A_Overlay creates a new sprite layer (which is handled by a new instance of PSprite) and sends that layer into the specified state sequence. That state sequence will be played on a separate layer. Note that you can create multiple layers that utilize the same state sequence (thus, independently showing multiple versions of the same animation on different layers).

To specify different behaviors for overlays, use A_OverlayFlags.

Parameters

  • int layer
Indicates the draw hierarchy for the layer. Higher numbered layers will be drawn over lower numbers.
There are several layer aliases that are used by GZDoom:
  • PSP_STRIFEHANDS (-1) - Used by A_ItBurnsItBurns in Strife. This should never be utilized by A_Overlay due to special hardcoded quirks.
  • PSP_WEAPON (1) - Used by the actual weapon. This should never be utilized by A_Overlay because it must not be overridden; the core weapon logic is tied to this layer. However, it's fine to use other overlay functions on this layer (like A_OverlayFlags, A_OverlayScale, etc.).
  • PSP_FLASH (1000) - Used by A_GunFlash. This can be freely utilized by custom overlays, if desired.
It's recommended that custom layers utilize values starting with -2 and below or 2 and above. The number of layers is not limited.
Using OverlayID() for layer will return the index of the layer used by the state sequence where this function is called. This is useful for other overlay functions but should not be used by A_Overlay because the layer will try to override itself.
  • statelabel start
The name of the state label that the overlay should draw.
  • bool nooverride
If set to true, the function will not create an overlay if the specified layer already exists.

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.

See Also