1 decade ago by drhayes
I wanted the player to be able to do combos in my RPGish game thing, so I wrote a combo manager. The instructions are in the readme, but briefly:
Tada! As always, happy to help and take suggestions via pull requests or messages or whatever.
It currently only works with keypresses, so you can't do anything like "hold down arrow then press left twice". I'm not super worried about this limitation for my game but if you need it to do this I'm sure we could figure it out.
// in ig.game.init... this.comboManager = new ComboManager(); var konami = ['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a']; var seconds = 2; comboManager.add(konami, seconds, function() { console.log('You did it!'); }); // later, in ig.game.update... this.comboManager.update();
Tada! As always, happy to help and take suggestions via pull requests or messages or whatever.
It currently only works with keypresses, so you can't do anything like "hold down arrow then press left twice". I'm not super worried about this limitation for my game but if you need it to do this I'm sure we could figure it out.