Quick Animations - Repaired
#1
Quick Animations - Repaired
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.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#2
Thus far I am confused on I'd actually call uppon this in game - or in a scene, but I shall look into it.
However, just out of curiosity: Why would you need this, why not use Animations? Less lag? Or the ability to place this as a background of sorts? In a map, or in a menuy screen? Or did I missunderstand the purpose of this entirely? I am confused XD'
Friendship is born at that moment when one person says to another: "What! You, too? Thought I was the only one." (C.S. Lewis)
For the time you're laughing, there's nothing wrong in the world. (Colin Mochrie)

If it's funny, make sure people laugh. If it's not funny, make it funny (unless it's actually really serious). (silvercheers)

Please don't spell my name "Yamina-chan". It's all small. Thank you =D
Reply }
#3
The system acts as a means to include an animation into whatever scene you wish, be it title screen, main menu, or whatnot with the animation comprised of a series of png files. So if you have a folder named "Bloody dripping Title" in your Graphics\Pictures, and have png files from 1.png, 2.png, 3.png on up to 10.png.... you could use this to make a title screen with a gruesome title with animated bleeding letters.

It was just that Seph's original system would not let you save the graphics in an encrypted project. This version fixes that issue. I was even told by Kain Nobel that while the MACL has Quick Animations within, it STILL did not fix this problem.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#4
I see.
It still sounds like it would result in quite a bit of lag, but the option is nice, I suppose. I'll look into this at some point, just to see what it'd be like =)
Friendship is born at that moment when one person says to another: "What! You, too? Thought I was the only one." (C.S. Lewis)
For the time you're laughing, there's nothing wrong in the world. (Colin Mochrie)

If it's funny, make sure people laugh. If it's not funny, make it funny (unless it's actually really serious). (silvercheers)

Please don't spell my name "Yamina-chan". It's all small. Thank you =D
Reply }
#5
so can i have multiple animations? this seems like it would save a lot of lag if i wanted to have a large scale battle sequence
Reply }
#6
Nah, the way this sounds is that whenever you reference a particular image in a script (or maybe with Show Picture?), it will instead reference and play out a sequence of images in a folder. So you don't have to code the animation yourself.
Reply }
#7
Partially. You reference a folder in the Graphics\Pictures folder alright. But you have to use a script to do so. The update method... er... execute method... must be called repeatedly so the system grabs the next .png file in the folder in sequence.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
#8
so then i can have multiple animations in multiple folders?
Reply }
#9
Actually, yes! You can have in the Graphics\Pictures folder subfolders like 'KasperFish' in one, 'KasperBass' in another and 'KasperTrout' in a third! Just that the first pic each folder is 1.png, the second is 2.png and so on in succession.

The original demo that SephirothSpawn had showed three distinct animations of... well... Final Fantasy's 'Sephiroth' in the title screen. The code I included as an example in the script was a toned down example only showing how to code one. But you can easily have more.

And I took a look at the MACL. The guy who told me was correct. They did include the original version in MACL without fixing it to use 'cached' graphics as I did in this version.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   ATOA Chanting Battle Animations DerVVulfman 9 17,862 01-12-2017, 01:46 PM
Last Post: Noctis
   Animations Trickster 4 9,732 01-15-2012, 05:32 AM
Last Post: Lupinos
   Quick Keys blazingamer 0 4,723 03-07-2008, 06:56 AM
Last Post: blazingamer
   AUDIO FIX - Battle Animations DerVVulfman 0 5,382 03-05-2008, 06:44 AM
Last Post: DerVVulfman



Users browsing this thread: 1 Guest(s)