Advertisement
Vlue

Animation Frame Rate

Aug 9th, 2012
2,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.05 KB | None | 0 0
  1. #Animation Frame Rate v1.1
  2. #----------#
  3. #Features: Make animations play at a faster rate allowing smoother animations
  4. #           and now allowing animations to play behind their targets.
  5. #
  6. #Usage:    Place #number in the name of any animation you want to change the
  7. #           frame rate of (i.e. #1)
  8. #          Place @ in the name of any animation you want to have play behind
  9. #           it's target.
  10. #          Place NM in the name if FLIP_ANIMATIONS is true and you don't wish
  11. #           an animation to be mirrored.
  12. #        
  13. #Customization: DEFAULT_RATE below for animations without # in their name
  14. #               FLIP_ANIMATIONS is for Side View Battle Systems that don't
  15. #                automatically mirror animations on enemies.
  16. #
  17. #Examples: Sword Slash #3
  18. #          Aura Boost @
  19. #          Combination! #1 @
  20. #
  21. #----------#
  22. #-- Script by: V.M of D.T
  23. #
  24. #- Questions or comments can be:
  25. #    given by email: sumptuaryspade@live.ca
  26. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  27. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  28. #
  29. #--- Free to use in any project, commercial or non-commercial, with credit given
  30. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  31.  
  32. class Sprite_Base
  33.  
  34.   #Change the default frame_rate for all animations here:
  35.   DEFAULT_RATE = 4
  36.   FLIP_ANIMATIONS = false
  37.  
  38.   alias new_asp animation_set_sprites
  39.  
  40.   def set_animation_rate
  41.     name = @animation.name
  42.     index = name.index("#")
  43.     index.nil? ? rate = DEFAULT_RATE : rate = name[index+1,1].to_i
  44.     index = name.index("@")
  45.     index.nil? ? z = 300 : z = -20
  46.     index = name.index("NM")
  47.     if index.nil? && FLIP_ANIMATIONS && @battler
  48.       @ani_mirror = true if @battler.is_a?(Game_Enemy)
  49.     end
  50.     @ani_z = z
  51.     @ani_rate = rate
  52.   end
  53.  
  54.   def animation_set_sprites(frame)
  55.     new_asp(frame)
  56.     @ani_sprites.each_with_index do |sprite, i|
  57.       next unless sprite
  58.       sprite.z = self.z + @ani_z + i
  59.     end
  60.   end
  61.  
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement