A_OverlayScale

From ZDoom Wiki
Jump to navigation Jump to search


Note: While the function described on this page is defined in the Actor class, it only works when called either from a PlayerPawn state, or from one of the StateProvider states handled by PSprite, such as Weapon's Ready/Fire/etc. state sequences or a CustomInventory's Use state sequence. It will have no effect in any other context (such as calling it from a weapon's DoEffect override). If there's a need to achieve a similar effect from a different context, obtain a pointer to the necessary PSprite and modify its fields directly.

Actor

action native void A_OverlayScale (int layer, double wx = 1, double wy = 0, int flags = 0)

Usage

Changes the scale of the overlay, affected by the pivot's position. ‎

GZDoom automatically trims empty space of images by default; as a result, when applying rotation/scaling to a sprite animation, even if all sprites in the animation have the same pixel dimensions, the pivot point used for rotation/scaling will be moved around for every sprite if they have different amounts of fully transparent pixels (which is almost always the case between different images). To avoid this, apply NoTrim via ANIMDEFS or TEXTURES to all graphics used in the animation.

Parameters

  • int layer
The layer to modify.
  • double wx
Sets the X scale.
  • double wy
Sets the Y scale. If 0, will automatically use whatever value was passed to wx.
  • int flags
Can be combined with the |:
  • WOF_RELATIVE - Takes into account the current rotation of the overlay.
  • WOF_ADD - The input adds instead of replaces the current offset, and implies WOF_INTERPOLATE.
  • WOF_KEEPX - The 'wx' parameter is ignored.
  • WOF_KEEPY - The 'wy' parameter is ignored.
  • WOF_ZEROY - If 'wy' is 0, it copies the 'wx' parameter. This flag disables that behavior.
  • WOF_INTERPOLATE - Enables interpolation for the frame called on. For backwards compatibility however, A_OverlayOffset will override the current interpolation setting if the function is called in the same tic.

Examples

This example shows how the Doom pistol muzzle flash could be modified, assuming you have a custom flash sprite that has a round shape. In this example the flash is drawn below the gun and is randomly scaled and rotated to add variety to its appearance:

Fire:
    PISG A 4;
    PISG B 6 
    {
        A_FireBullets(5.6, 0, 1, 5);
        A_StartSound("weapons/pistol", CHAN_WEAPON);
        A_Overlay(-100, "Flash"); // Draw the flash below the gun rather than above it
    }
    PISG C 4;
    PISG B 5 A_ReFire;
    Goto Ready;
Flash:
    PISG Z 6 bright // Meant to be a custom sprite; doesn't exist in Doom
    {
        A_Light1();
        // Set the pivot point to the center of the sprite:
        A_OverlayPivot(OverlayID(), 0.5, 0.5);
        // Scale it randomly between 85% and 100% of its
        // size (using 0 for the second argument makes it
        // use the same value as the first one):
        A_OverlayScale(OverlayID(), frandom(0.85, 1), 0);
        // Rotate the sprite randomly:
        A_OverlayRotate(OverlayID(), frandom(0,360));
    }
    TNT1 A 0 A_Light0;
    stop;

See Also