Usage example for timer?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
gordebak
Prole
Posts: 37
Joined: Tue Dec 27, 2011 6:38 am

Usage example for timer?

Post by gordebak »

For example, I have an explosion animation for my character. It's fine. But if I want to do something when the character dies, like showing a text or image, it happens immediately. I want my explosion animation finished before anything happens. Should I use timer for this?
User avatar
richapple
Citizen
Posts: 65
Joined: Sun Dec 25, 2011 10:25 am

Re: Usage example for timer?

Post by richapple »

You can:
1. Try to write a timer for yourself. (It can be easy if you won't use it a lot, but It can be tedious and It would be much easier and time-saving to choose second way)
2. Use a timer library by kikito called cron or Hump.timer by vrld.

Cron
Cron has some useful functions like:

Code: Select all

cron.after(time, callback)   will execute callback after the given amount of time

Code: Select all

cron.every(time, callback)   will repeat the same action periodically


You can download cron.lua at github,
view tutorial here
or here.

Hump (Helper Utilities for Massive Progression):
I didn't use hump.timer yet but you can read documentation and tutorials about hump here
and download here

Hope this helps!
gordebak
Prole
Posts: 37
Joined: Tue Dec 27, 2011 6:38 am

Re: Usage example for timer?

Post by gordebak »

Thanks, it seems like what I needed.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests