Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

9 years ago by SalteMishel

Hi All,

ig.input.bind( ig.KEY.UP_ARROW, 'jump' );

If there a way to track the input key or name such as 'jump' or ig.KEY.UP_ARROW
to be used in switch case? Thanks

9 years ago by Joncom

What would be the purpose of using the "jump" event with a switch-case?

Why wouldn't you just say:
/* your-entity.js */
update: function () {
    if(ig.input.state('jump')) {
        handle_jump();
    }
    this.parent();
}

?

9 years ago by SalteMishel

Hi Joncom,

That's because I have 26 alphabets to take care of and I need a way to get reference to the input key's name either 'jump' or ig.KEY.UP_ARROW
I might not even be using switch case you can imagine that I needed something like a keyboard and typing. like
if(ig.KEY.anyAlphabet==true){
string+=ig.KEY.anyAlphabet;
and some other actions
}

Thanks.

9 years ago by Joncom

Take a look at input.js at how the state function works. I believe it accesses an array or object you could loop through to capture inputs in a more "bulk" fashion than the simple "if-key-is-down-do-this" method.
Page 1 of 1
« first « previous next › last »