Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #========================================================================
- # LOOPING ANIMATIONS
- # Version 1.0
- # Author: Shaz
- #------------------------------------------------------------------------
- # DESCRIPTION
- # Allows you to set an animation (from the Animation database) on an
- # event to loop endlessly, optionally starting on a specific frame.
- #------------------------------------------------------------------------
- # TO INSTALL
- # Copy and paste into a new slot in Materials.
- # This script overwrites Sprite_Character.setup_new_effect and
- # Sprite_Character.end_animation and should be placed above any
- # other scripts that alias those methods.
- # No customization necessary.
- #------------------------------------------------------------------------
- # TO USE
- # Call the method start_anim_loop(anim_id[, start_frame]) on the character
- # (which could be the player, a follower, a vehicle or an event) to start
- # a looping animation.
- # When starting at a frame other than 1, only the first play will start at
- # that frame - when it finishes, it will go back to frame 1 to play again.
- # Call the method end_anim_loop on the character to stop it repeating after
- # the current loop is finished.
- #------------------------------------------------------------------------
- # EXAMPLES
- # $game_player.start_anim_loop(15) - to loop animation 15 on the player
- # $game_map.events[5].start_anim_loop(8, 20) - to play animation 15 on
- # event 5, starting at frame 20 for the first pass
- # Set Move Route (EV015): start_anim_loop(3, 10) - to use a move route to play
- # animation 3 on event 15, starting at frame 10 for the first pass
- # $game_player.end_anim_loop - to stop looping animation on player
- # Set Move Route (EV015): end_anim_loop - to stop the animation looping
- # on event 15
- #------------------------------------------------------------------------
- # VERSIONS
- # 20 July 2013 1.0 Initial Release
- # 7 Feb 2014 1.1 Fixed slight delay between ending/restarting
- #========================================================================
- class Game_CharacterBase
- attr_reader :loop_animation # animation loops
- attr_accessor :start_frame # animation start frame
- alias shaz_ra_init_public_members init_public_members
- def init_public_members
- shaz_ra_init_public_members
- @loop_animation = false
- @start_frame = 1
- end
- def start_anim_loop(anim_id, start_frame = 1)
- @loop_animation = true
- @animation_id = anim_id
- @start_frame = start_frame
- end
- def end_anim_loop
- @loop_animation = false
- end
- end
- class Sprite_Character < Sprite_Base
- def setup_new_effect
- if !animation? && @character.animation_id > 0
- animation = $data_animations[@character.animation_id]
- start_animation(animation)
- if @character.start_frame != 1
- @ani_duration = (animation.frame_max - @character.start_frame) * @ani_rate + 1
- @character.start_frame = 1
- end
- end
- if !@balloon_sprite && @character.balloon_id > 0
- @balloon_id = @character.balloon_id
- start_balloon
- end
- end
- def end_animation
- if @character.loop_animation
- @ani_duration = @animation.frame_max * @ani_rate + 1
- else
- super
- @character.animation_id = 0
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment