Looping Animations

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV

Looping Animations (V1.1)
Shaz




Introduction
Play a looping animation on a character, optionally starting somewhere other than the beginning.

Versions

Spoiler



20 July 2013 1.0 Initial Release
7 Feb 2014 1.1 Fixed slight delay between ending/restarting



Features
- Animation loops without need for parallel process or loop event commands.
- Play looping animation over player, followers, events or vehicles.
- Start playing in the middle of an animation rather than from the beginning.
- Animation continues looping while on the map, or until you tell it to stop.

How to Use
Paste into Materials section.
Script overwrites Sprite_Character.setup_new_effect and Sprite_Character.end_animation methods, and should go above any other scripts that alias these methods.

Use a script call to start or end the animation, with the player, follower, event or vehicle as the subject. For example:

Call Script: $game_player.start_anim_loop(15)
- to loop animation 15 over the player

Call Script: $game_map.events[5].start_anim_loop(8, 20)
- to loop animation 8 over event 5, but starting from frame 20 the first time through

Set Move Route (EV015): start_anim_loop(3, 10)
- to loop animation 3 over event 15, but starting from frame 10 the first time through

Call Script: $game_player.end_anim_loop
- to stop the animation on the player repeating

Set Move Route (EV015): end_anim_loop
- to stop the animation on event 15 repeating


Script


Download from pastebin

FAQ


Credit and Thanks
- Shaz (Sharon Hanlon)
- May be used in commercial and non-commercial games, when credit is given
- Do NOT repost on other sites - instead, provide a link back to this thread

Author's Notes
- Not to be used in conjunction with the Show Animation event command - if you wish to use this command and a looping animation is already playing, make sure you call end_loop_anim on the event first, and allow time for the current pass to finish.
 
Last edited by a moderator:

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,309
Reaction score
531
First Language
indonesian
i suggest adding feature:

start from beginning/any frame. but loop from certain frame after that. (or if possible loop from certain frame to certain frame only after that).
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
As my time is limited, I write my scripts to meet my needs, and I share them if I think others will find them useful, but I don't make them super-flexible for any possible use others may think of.


However, you are more than welcome to mod the script for your own purposes, or to have someone else do it for you, if you actually have such a need.
 
Last edited by a moderator:

Lamsah

Villager
Member
Joined
Jun 2, 2013
Messages
26
Reaction score
5
Primarily Uses
This is nice Shaz, i can definitely use this =D
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,309
Reaction score
531
First Language
indonesian
@shaz: ah okay then. i guess i'll edit it myself :D . thx btw for this script.
 

Gryffin

Villager
Member
Joined
Dec 15, 2013
Messages
21
Reaction score
2
First Language
English
Primarily Uses
Thank you for the script.

I'm having some trouble with the animation looping properly.

It seems that at least my animation, if not every animation, has one frame that is blank. So that when it loops, there is a frame inbetween the loop where the animation disappears.

I have a custom six-frame animation that definitely has a graphic on each frame. I've also tested with other, stock animations, and they appear to have the same issue.
To start the loop, I run this script in the event: $game_map.events[3].start_anim_loop(116)
Is anyone aware of a hard-coded blank frame? Or is there something I'm doing wrong? Thank you in advance.

The animation and event:



 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Okay, I'm home now and have taken a quick look at this issue. You've either got really good eyesight, or an animation that makes it really obvious that a frame is being skipped. It's not really - there's just a moment between the end of one iteration and the start of another.


I have made a very slight change to the way the animation restarts when it's finished, and it seems to have solved the problem. Please grab the code again (from the initial post) and replace what you currently have in your project. Let me know if it works, and more importantly, if there are any OTHER problems that I may have introduced in the meantime.
 

Gryffin

Villager
Member
Joined
Dec 15, 2013
Messages
21
Reaction score
2
First Language
English
Primarily Uses
Yay! That fixed it perfectly, or it least it fixed this issue. I've yet to notice any new glitches that may have been introduced.

Thank you very much for your help and for addressing this promptly.
 

Warganto

Villager
Member
Joined
Jun 22, 2014
Messages
14
Reaction score
0
Primarily Uses
Hello, is it possible to make an animated cursor when hoovering over an event with this script "Super Simple Mouse System"?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Did you post on my blog? The animation on this script, and the icon on the mouse script, use quite different methods to display the sprites. I could adjust that script, but it won't be by some kind of merging with this one.
 

Warganto

Villager
Member
Joined
Jun 22, 2014
Messages
14
Reaction score
0
Primarily Uses
Did you post on my blog? The animation on this script, and the icon on the mouse script, use quite different methods to display the sprites. I could adjust that script, but it won't be by some kind of merging with this one.
Yes i did. I'm sorry if it wasn't appropriate ;`(
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
no, that's fine. I figured after I read your other post that it was you :)
 

Shana

Villager
Member
Joined
Jan 21, 2015
Messages
20
Reaction score
0
First Language
German
Primarily Uses
Since I was asked to, I'll post it here instead:

I found the Looping Animations script today and I must say it really does the trick for me. There's just one thing bothering me tho. I've done some animations with different levels of speed and I want them to be changeable. For example: While Animation 1 is playing, I press the "2" key and it swapps to the other animation I specified. I already have a key input script in place and it works as i see it writing the variables I specified. However, your script doesn't seem to change animations when I want it to, not even with the end animation call before calling a new one. Only when I I hit F9 (the switched / variables screen) does it change for some reason. If anyone can provide me with some help I'd really appreciate that.



This is a screenshot of how I tried to do it. There's an NPC activating the testswitch. After that, Animation 0 starts and loops without any flaws.

When I press keys 0~3 the testvariable gets written with either 0, 1, 2 or 3 (it is how I configured it with $D13x - Common Event Keys). I viewed the variable again after each press of a button and I saw it working.

However, the animation still does not seem to change. Tried in on the player, on the events on that map, everything. But to no avail as of now. It only swapped animations when I pressed F9 to view the variable and exited that menu.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Try putting a Wait 1 Frame between ending the animation and starting the next one?
 

Shana

Villager
Member
Joined
Jan 21, 2015
Messages
20
Reaction score
0
First Language
German
Primarily Uses
Hmm. It semi-works. The animation does switch but it becomes non-seamless again due to it repeating because of it being a parallel process and that 1 frame wait gets displayed unfortunately. Trying to let it run through the process only once doesn't seem to help either.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Well, that's because you have it in a parallel process and you're not catering for when you're NOT pressing a key (so when it stays as the same animation). You only want to run those commands once, then allow it to loop on its own until you press a different key. But in a parallel process, it's going to keep repeating.


What turns switch 100 on and off?
 
Last edited by a moderator:

Shana

Villager
Member
Joined
Jan 21, 2015
Messages
20
Reaction score
0
First Language
German
Primarily Uses
It's an NPC - for now. Tested it with switchin it on and off via these common events as well, didn't work either. Tested it with it being no parallel process and calling it through these events as well, didn't work either. Geez : / If only the standard animation display would loop seamlessly like it did back in Rm2k3 I wouldn't have any problems. *sigh*
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
turn switch 100 off at the end of the loop so it doesn't keep looping.
 

Shana

Villager
Member
Joined
Jan 21, 2015
Messages
20
Reaction score
0
First Language
German
Primarily Uses
Well, that's what I did exactly x) Still doesn't work. Oh well, guess I'll have to brainstorm hard for a workaround.
 

Mireneye

High Chromancer
Veteran
Joined
Dec 22, 2013
Messages
143
Reaction score
20
Primarily Uses
First Shaz thanks for a great little script! And for your efforts, greatly appreciated! I've run into a bit of a functional problem, sadly I think these are the hardest ones to track down. See I'm running XAS, XAS is running the relevant code which is this:

#===============================================================================# ■ Sprite_Character#===============================================================================class Sprite_Character < Sprite_Base  include XAS_SYSTEM    #--------------------------------------------------------------------------  # ● Setup New Effect  #--------------------------------------------------------------------------                def setup_new_effect      if @character.animation_id > 0         animation = $data_animations[@character.animation_id]         start_animation(animation)         @character.animation_id = 0      end      if !@balloon_sprite && @character.balloon_id > 0         @balloon_id = @character.balloon_id         start_balloon      end  end  
And mind you I'm no scripter so you'll have to tell me where to look and what to look for if I am to help track this thing down. Now XAS is an action battle system, it will load from the database from Skills the Animation. I'm using animation 152 for most weapons. This is essentially a bleeding animation. It will play if the Skill hits it's target. Now I don't quite recall how but I was able to make it so this animation does not play for some "enemies" like grass. Yeah grass is setup like an enemy. But upon installing your script grasses and the like started bleeding again which is super weird.

I'm sorry if I'm vauge, I'm just not quite well versed in what is going on but I'm dedicated to do what it takes to figure this out. Or try alternative routes. Anyhoo, thanks in advance ^-^ 
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top