Fade Events
Authors: Heretic
Version: 1.0
Type: Fade Events with Duration
Key Term: Misc Add-on
IntroductionThis script will allow you to Fade Events in and out gradually. The Default Options allow you to change an events opacity, but does not allow you to make a gradual transition. Thus, if you wanted to have an Event that "dissolved", "teleported" or "flickered", you would have to use quite a few Change Opacity commands, then use Wait after each and every Change Opacity command. Sorry to say, but I think that is a pain in the behind. This script offers an easier way to accomplish that same effect by using one line of script: fade_event(new_opacity, duration). Short Fades can be accomplished without this script by adjusting the opacity every frame for a few frames, but if you need rather long Fades that take a lot of frames, then this is the script for you!
Features
- Saves Time by changing Opacity for you Automagically
- Super Duper easy to use
- Only ONE Command to Remember
- No Configuration Necessary
- High Degree of Compatability
- Reported to me to be compatible with VX and VXA as well
Screenshots
Demohttp://www.775.net/~heretic/downloads/rmxp/fade_event/fade_event.exe
ScriptFade Event (with Developer Errors)(has a little more code, lets you know if you do something wrong)
# Name: Fade Event (With Developer Errors)
# Author: Heretic
# Ver: 1.0
# Date: Yes, please, but with a pretty girl! (yes, that was a joke!)
# Timestamp: Apr 23rd, 2012
#
# FADE EVENT is Super simple to use. Put above Main somewhere.
#
# Pretty much anywhere between Scene_Debug and Main should be fine.
#
# In the Editor, in Edit Events, go to Set Move Route, and hit Script
# in that window, enter "fade_event(255, 20)" without the quotes
# and adjust 255 for Not Transparent to 0 for Fully Invisible
# the second number is the number of Frames for the Transition
#
# Note: 1 Second in RMXP is 20 Frames
module Fade_Events #(for including in any new or custom classes)
#--------------------------------------------------------------------------
# * Fade Event - (Opacity 0 to 255, Duration in Frames)
#--------------------------------------------------------------------------
def fade_event(arg_opacity_target, arg_opacity_duration)
if arg_opacity_target.nil? or arg_opacity_duration.nil?
print "fade_event(opacity, duration) expects Two Arguments\n"
return
elsif not arg_opacity_target.is_a? Numeric
print "\"", arg_opacity_target, "\" is not an Number!\n",
"Both Arguments should be Numbers!\n\n",
"I.E. fade_event(255,20)"
return
elsif not arg_opacity_duration.is_a? Numeric
print "\"", arg_opacity_duration, "\" is not an Number!\n",
"Both Arguments should be Numbers!\n\n",
"I.E. fade_event(255,20)"
return
elsif arg_opacity_target < 0 or arg_opacity_target > 255
print "\"", arg_opacity_target, "\" Opacity Out of Range\n",
"Valid Range: 0 - 255"
elsif arg_opacity_duration < 0
print "\"", arg_opacity_target, "\" Duration Out of Range\n",
"Valid Range: Any Positive Number or 0"
end
self.opacity_target = arg_opacity_target * 1.0
self.opacity_duration = arg_opacity_duration.abs
if self.opacity_duration == 0
self.opacity = self.opacity_target.clone
end
end
#-----------------------------------------------------------------------------
# * Change Event Opacity
#-----------------------------------------------------------------------------
def change_event_opacity
# Manage change in Event Opacity Level
if @opacity_duration >= 1
d = @opacity_duration
@opacity = (@opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
class Game_Character
attr_accessor :opacity_target
attr_accessor :opacity_duration
attr_accessor :original_opacity
unless self.method_defined?('fade_events_initialize')
alias fade_events_initialize initialize
end
def initialize
# Initilaize Original First
fade_events_initialize
# Added Properties
@opacity_target = 255
@opacity_duration = 0
@original_opacity = @opacity
end
# IF the method hasn't been defined yet
unless self.method_defined?('fade_events_update')
alias fade_events_update update
end
# Redefine Updater
def update
# Run Original First
fade_events_update
if @opacity_duration >= 1
# Manages the Events Current Opacity
change_event_opacity
end
end
# Check if the Fade_Event is already Defined (prevents errors)
unless Game_Character.included_modules.include? (Fade_Events)
# Make the functions inside the Module available to this class
include Fade_Events
end
end
class Interpreter
def fade_event(opacity, duration)
print "Please call \"fade_event\" from\n",
"\"Edit Event\" -> \"Set Move Route\" -> Scripts Window\n",
"instead of \n\"Edit Event\" -> Scripts Window"
end
end
Fade Event (no Developer Errors)(has less code, no errors displayed if you do something wrong, so you're on your own)
# Name: Fade Event (No Developer Errors)
# Author: Heretic
# Ver: 1.0
# Date: Yes, please, but with a pretty girl! (yes, that was a joke!)
# Timestamp: Apr 23rd, 2012
#
# FADE EVENT is Super simple to use. Put above Main somewhere.
#
# Pretty much anywhere between Scene_Debug and Main should be fine.
#
# In the Editor, in Edit Events, go to Set Move Route, and hit Script
# in that window, enter "fade_event(255, 20)" without the quotes
# and adjust 255 for Not Transparent to 0 for Fully Invisible
# the second number is the number of Frames for the Transition
#
# Note: 1 Second in RMXP is 20 Frames
module Fade_Events #(for including in any new or custom classes)
#--------------------------------------------------------------------------
# * Fade Event - (Opacity 0 to 255, Duration in Frames)
#--------------------------------------------------------------------------
def fade_event(arg_opacity_target, arg_opacity_duration)
self.opacity_target = arg_opacity_target * 1.0
self.opacity_duration = arg_opacity_duration.abs
if self.opacity_duration == 0
self.opacity = self.opacity_target.clone
end
end
#-----------------------------------------------------------------------------
# * Change Event Opacity
#-----------------------------------------------------------------------------
def change_event_opacity
# Manage change in Event Opacity Level
if @opacity_duration >= 1
d = @opacity_duration
@opacity = (@opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
class Game_Character
attr_accessor :opacity_target
attr_accessor :opacity_duration
attr_accessor :original_opacity
unless self.method_defined?('fade_events_initialize')
alias fade_events_initialize initialize
end
def initialize
# Initilaize Original First
fade_events_initialize
# Added Properties
@opacity_target = 255
@opacity_duration = 0
@original_opacity = @opacity
end
# IF the method hasn't been defined yet
unless self.method_defined?('fade_events_update')
alias fade_events_update update
end
# Redefine Updater
def update
# Run Original First
fade_events_update
if @opacity_duration >= 1
# Manages the Events Current Opacity
change_event_opacity
end
end
# Check if the Fade_Event is already Defined (prevents errors)
unless Game_Character.included_modules.include? (Fade_Events)
# Make the functions inside the Module available to this class
include Fade_Events
end
end
InstructionsJust put the code above main somewhere...
CompatibilityNo Incompatability Issues, as far as I know...
Credits and Thanks
- I'd like to thank the Academy, Chucky Cheese, and inspiration from Chuck Norris!
- Thanks to everyone who has been helping me improve my scripting skills!
Author's NotesThursday is Garbage Day so don't forget to take out the Trash! Oh, wait, that isnt really a note related to this Script! How embarassing!
---
I dont own copies of VX or VXA, but it has been reported to me that this script is compatible with VX and VXA as well! Please advise if there are any issues and I'll see what I can do for you.