Gradient FX Module

Started by Gal Shemesh, Tue 05/08/2025 21:02:51

Previous topic - Next topic

Gal Shemesh

About:
This is a nice pattern effect module for making graphics either disappear or reveal using a drawn pixel pattern.



Installation:
Import the GradientFX.scm script to your AGS game.

Usage:
You can use the effect to either Hide or Show an OBJECT, a CHARACTER, or even use it as a transition* effect when changing rooms.

* For using this as a transition, set the 'Default transition when changing rooms' property in General Settings to 'Instant' and use 'player.ChangeRoomGradientFX()' when changing rooms.

When using the function to hide* or show** an OBJECT, use the following functions for drawing the effect at the center of its graphic sprite:

Object.GraphicWidthCenter();
Object.GraphicHeightCenter();

- These functions returns the correct coordinates for showing the gradient effect sprites overlay at the same position of either the Object or Charcter, so you won't need to manually position the overlays for each type.

When using the function to hide* or show** a CHARACTER, use these following functions instead:

Character.GraphicWidthCenter();
Character.GraphicHeightCenter();


*To hide a sprite:
1. Hide the current object if it's an object or set transparency to 100 if it's a character before calling the function.

2. Call 'gradientFX(sprite.graphic, x, y, int delay, bool reverse = false);
*the reverse optional bool is used for playing the effect backwards (see 'show a sprite' below).

Example for making a character disappear using this effect:

Code: ags
function room_AfterFadeIn()
{
  player.Transparency = 100;
  gradientFX(player.GetFrameGraphic(), player.GraphicWidthCenter(), player.GraphicHeightCenter(), 5);
}


**To show a sprite:
1. Hide the current object if it's an object or set transparency to 100 if it's a character before calling the function.

2. Call 'gradientFX(sprite.graphic, x, y, int delay, bool reverse = true);

3. Show the object if it's an object or set transparency to 0 if it's a character after calling the function.

Example for making a character appear using this effect:

Code: ags
function room_AfterFadeIn()
{
  player.Transparency = 100;
  gradientFX(player.GetFrameGraphic(), player.GraphicWidthCenter(), player.GraphicHeightCenter(), 5, true);
  player.Transparency = 0;
}

You may download the module from my personal Dropbox.


Changelog
=========
Version 1.0.2
Released: 6th August 2025
- The 16x16 pattern is now random (thanks to @Kara Jo Kalinowski!)

Version 1.0.1
Released: 6th August 2025
- Removed a mistaken 2nd argument in the on_event function, causing a conflict with on_event functions of 1 argument in other scripts.

Version 1.0.0
Released: 5th August 2025
Notes: Initial release

Danvzare

Ooh, this is cool!  8-0
I probably could've used something like this about a month ago.  (laugh)

SMF spam blocked by CleanTalk