freezedev / lyria

Lightweight DOM-based game framework
The Unlicense
8 stars 0 forks source link

Lyria.Events #5

Closed frostney closed 11 years ago

frostney commented 11 years ago

Add a similar mechanic that Lyria.Loop has for timed or intervaled events.

Pseudo-code:

Lyria.Events.add('myEvent', function() { console.log('called myEvent'); });

// myEvent will be called right now
Lyria.Events.fire('myEvent');

// myEvent will be called in 3000 ms
Lyria.Events.fire('myEvent', 3000);

// myEvent will be called each 3000 ms - look for a better name (fireEach is not really ideomatic)
Lyria.Events.fireEach('myEvent', 3000);
Polooo2 commented 11 years ago

// myEvent will be called each 3000 ms - look for a better name (fireEach is not really ideomatic) Lyria.Events.fireEach('myEvent', 3000);

fireAlways() ??

frostney commented 11 years ago

The API is a bit different from the original proposal, it's actually pretty much the same as https://github.com/elysion-powered/elyssa/blob/master/src/core/events.coffee