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

5 years ago by Daryl

Hey guys,

I'm quite new to ImpactJs and really like how the engine is built. Ive gotten to a bit of a problem however.

When trying to bind the left mouse key to an input in main.js it doesnt work but right key does.

init: function() {
..
ig.input.bind(ig.KEY.MOUSE1, 'leftclick');
ig.input.bind(ig.KEY.MOUSE2, 'click');
..
}

update: function() {
..
if(ig.input.pressed('click')) {console.log('right click')}
if(ig.input.pressed('leftclick')) {console.log('left click');}
..
}

Am I doing anything wrong? Any help would be appreciated!

5 years ago by stahlmanDesign

Your code looks right. What happens if you change pressed to state, to check the state of the press?

Tip: You can wrap your code in two # symbols to get code highlighting like this:

init: function() {
..
ig.input.bind(ig.KEY.MOUSE1, 'leftclick');
ig.input.bind(ig.KEY.MOUSE2, 'click');
..
}

update: function() {
..
if(ig.input.pressed('click')) {console.log('right click')}
if(ig.input.pressed('leftclick')) {console.log('left click');}
..
}

5 years ago by Daryl

Nothing - other than the fact that it will print out a string of 'right click' when i press down the right button and nothing when i press down the left. :/

When you use this - it just works or?

Ps: thanks for the tip!

5 years ago by Daryl

FOUND OUT!

Okay so the problem was that I am using gui.js, which puts the event at mouse1, and even if you write it in the init() it will just get over written!

Can't believe this, >_< Thanks for your help anyway!

5 years ago by Datamosh

I recently noticed and answered your issue on github. Sorry for the problem, I saw this topic but did not relate with my plugin impact-gui.

Some time ago someone had a similar problem and I added this information to the readme:
https://github.com/datamosh/ImpactJS-GUI#mouse-binds-important

I'm sorry!
Page 1 of 1
« first « previous next › last »