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

1 decade ago by dmen

I have a game that is complete, built for MS Surface. It plays great on surface aside from an issue I'm having with mouse events not working properly. I have successive entity screens with a NEXT button in the same location on each.
I bind the mouse with specific names to avoid successive presses... it just doesn't work on surface.
For example in the first entity I do:
ig.input.bind(ig.KEY.MOUSE1, 'avatar1');
and then check like:
if (ig.input.pressed('avatar1')) {
check mouse coords in here...

Then I swap entities and do like:
ig.input.bind(ig.KEY.MOUSE1, 'avatar2');

Works find in standard Win8 but on the surface I press down in the first entity... entity swaps... and then when you release the mouse I get a press in entity 2.

What to do? I really don't want to have to switch button positions to eliminate the problem.

1 decade ago by Joncom

Maybe bind your mouse only once.

ig.input.bind(ig.KEY.MOUSE1, 'click');

And then attach the "action" logic to the button itself.

/* main.js */
avatar: 'avatar1',

update: function() {
    this.parent();
    if(ig.input.pressed('click') && mouseIsOver(ig.game.nextButton)) {
        ig.game.nextButton.onClick(); // invoke button action
    }
}

/* button.js */
onClick: function() {
    var avatar = ig.game.avatar;
    // do something with the avatar
    ig.game.avatar = 'avatar2';
}
Page 1 of 1
« first « previous next › last »