01-25-2013, 06:15 AM
Quick Animations - Repaired
Version: 1.0
Based on the work of SephirothSpawn
Version: 1.0
Based on the work of SephirothSpawn
Introduction
The original Quick Animations by SephirothSpawn answered a call placed by people wondering if it would be possible to show cell animations of a sort in RPGMaker XP, similar to the animations performed by an Animated Gif. His method made use of assigning a folder that had a series of .png files numbered from 1.png on up, and playing them in sequence. The drawback, however, was that the folder was not specified as one of the Cache files in the Graphics folder, and was not saved/stored or accessible withing the encrypted .rgssad folder.
This rewrite of his system lets you create folders within the Graphics\Pictures folder which will be encrytped and playable from your final product.
Script
Yes... the script. And not even a download, but right here. It was just too easy an edit.
Code:
#==============================================================================
# ** Quick Animations - Repaired
# Based on SephirothSpawn's work (2006-07-06)
#==============================================================================
# Version 1.0
# by DerVVulfman
# 01-24-2012
#------------------------------------------------------------------------------
# * Instructions
#
# ~ Creating Animation
#
# <object_name> = Quick_Animation.new(directory, loop, frame_skip, viewport)
#
# directory : Directory in your Graphics\Pictures Folder for the image set.
# loop : true (image loops) or false (image plays and disposes itself)
# frame_skip : number of frames to proceed to next image
# viewport : viewport of image
#
# ~ Object must execute, or frames won't pass through.
# ~ Don't update a object after it disposes. A quick way around of this
#
#------------------------------------------------------------------------------
#
# SAMPLE CODE:
#
# -- assuming there is a directory called GIFS in your Pictures folder
# -- assuming the .png files within are 1.pic, 2.pic, 3.pic... etc
#
# class Scene_Title
# alias seph_demo_scnttl_main main
# alias seph_demo_scnttl_update update
# def main
# @image1 = Quick_Animation.new('GIFS/', true, 5)
# @image1.x = 224
# @image1.y = 238
# @image1.z = 9999
# seph_demo_scnttl_main
# @image1.dispose
# end
# def update
# seph_demo_scnttl_update
# @image1.execute
# end
# end
#
# -- A base mirror of SephirothSpawn's original demo code, though I only
# -- desired to show one of the image sets instead of the three. Very
# -- little was done to the commands and users of the original should
# -- have almost no issue learning how to use the new variant.
#
#------------------------------------------------------------------------------
#
# NOTES REGARDING THE ORIGINAL:
#
# Changes were added so the graphics can be cached and stored within an
# encrypted archive. The previous version did not account for this.
#
# The previous system included an 'update' method to be called. This was
# abandoned and replaced with an 'execute' command to avoid an occurring
# stack error.
#
#==============================================================================
#==============================================================================
# ** RPG::Cache
#------------------------------------------------------------------------------
# This is a module that loads each of RPGXP's graphic formats, creates a
# Bitmap object, and retains it.
#==============================================================================
module RPG::Cache
#--------------------------------------------------------------------------
# * Test Cache File #1 (no hue option)
# type : cache type (autotile, icon, picture, etc.)
# filename : filename of the cached bitmap
#--------------------------------------------------------------------------
def self.test_1(type, filename)
failed = false
begin
bitmap = eval("self.#{type}(filename)")
rescue Errno::ENOENT
failed = true
end
return !failed
end
end
#==============================================================================
# ** Quick_Animation
#==============================================================================
class Quick_Animation < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
# ~ directory : foldername in Pictures Folder
# ~ loop : true or false to loop or not loop image
# ~ frame_skip : number of frames to advance next image
# ~ viewport : viewport on window
#--------------------------------------------------------------------------
def initialize(directory, loop = true, frame_skip = 10, viewport = nil)
super(viewport)
# Stores Directory, Loop & Frame Skip Count
@directory, @loop, @frame_skip = directory, loop, frame_skip
# Starts Index Count
@index = 0
# Updates Bitmap
execute
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def execute
# Stop Unless Frame Skip Reached
return unless Graphics.frame_count % @frame_skip == 0
@index = 0 if @index.nil?
# Adds 1 to the index
@index += 1
# If not Last Image
filename = @directory + @index.to_s
if RPG::Cache.test_1('picture', filename)
# Sets Bitmap
self.bitmap = RPG::Cache.picture(@directory+ @index.to_s)
# If Last Image Already Displayed
else
# If Loop Image
if @loop
# Reset Index & Update Bitmap
@index = 0
update
# If No Loop
else
# Delete Image
self.dispose
end
end
end
end
Instructions
Pretty much in the script. It may take a little time to get the hang of it.
Compatibility
Designed mainly for use with RPGMaker XP. however I don't see much editing necessary for use with RPGMaker VX. Not sure about VXAce though.
Terms and Conditions
Free for use. Just give proper credits. Not just for I, but SephirothSpawn who made the bulk of the script.