Timer - Call methods after X frames

TDD_Timer.png
1.0.1


Ever wanted to call a sound effect in your scripts after, say, 30 frames have passed? Or how about wait 60 seconds before you render a sprite with the bitmap Cache.system("gone_4_60_s")? Well now you can, with this teeny tiny and easy-to-use script!

Introducing the fantabulous TDD::Timer.call_after_frames!

how_it_works.png


You use it like this:

TDD::Timer.call_after_frames( :frames => Number, - Number of frames to wait before calling :method 😮bserver => Object, - Object for which method should be called :method => :symbol, - Method to call on 😮bserver Object 😛arams => Object, - OPTIONAL: Any object you wish to pass to the :method)Real world example:

Spoiler
Here it is used (in combination with my Ease animation script) to match the sound effects to the animation, by using delayed calls to methods that call the sound effect:



One of those calls look like this:

# Audio: Play fall againTDD::Timer.call_after_frames(observer: self, method: 😛lay_shatter_sfx, frames: 170) 
installation.png


You know the drill: Put it somewhere below ▼ Materials but above ▼ Main Process

download.png


You can get it on github directly here; this link will always be up-to-date with the latest stable version:

https://raw.githubusercontent.com/TorD/TDD-Timer/master/script.rb

If you want to follow the development, or report bugs, please use the GitHub repository found here:

https://github.com/TorD/TDD-Timer

license.png


Free for non-commercial and commercial use. Credit greatly appreciated but not required. Share script freely with everyone, but please retain the description area unless you change the script completely. Thank you.

 

credits.png


Galenmereth / Tor Damian Design

 

 

Feeling generous?

If you would like to give me a small tip to help me spend even more time making and maintaining these free scripts, do consider supporting me on Gratipay. Any and all support will be greatly appreciated.
Similar as Invoke function in Unity. Good work! 😀

Original thread: https://forums.rpgmakerweb.com/threads/timer-call-methods-after-x-frames.34671/