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 end3r

I wanted to overwrite an ig.Input.mousemove() method because I changed the scaling of my Canvas (fullscreen using CSS3 transforms) and the mouse position is different than it should be. I want to replace ig.Input.mousemove() with my own, but I somehow can't do it using Extend or by adding eventListener to mousemove, because the old values stays. I can do it by changing two lines in the ImpactJS source code, but that's not an option.

My target values are mouse.pos.x and mouse.pos.y and they are assigned in the mousemove method - that's why I'm interested in it in the first place.

Any help with the idea or sample code how I can achieve that?

1 decade ago by Joncom

You may find inject helpful.
ig.Input.inject({
    mousemove: function( event ) {      
        // Do your own math.
        this.mouse.x = new_x;
        this.mouse.y = new_y;
    }
});

1 decade ago by end3r

Wow, I must have missed the Inject functionality somehow - now it works, thanks so much!
Page 1 of 1
« first « previous next › last »