mohammad-ahmadi Posted January 9, 2017 Share Posted January 9, 2017 Here's the thing: If I create a sprite or graphics, and add a mousemove handler for it, then what I expected to happen was that whenever I move my mouse over that element, that handler gets fired, but that's not what's happening, and that handler gets fired when you move the mouse over the entire canvas, why is that? var el = new PIXI.Graphics(); el.interactive = true; el.buttonMode = true; el.beginFill(0x00FFFF, 1); el.lineStyle(4, 0xFF0000, 1); el.drawRect(0, 0, 100, 100); el.endFill(); el .on('mousemove', move) .on('touchmove', move); stage.addChild(el) function move() { console.log('mousemove on this element?'); } Quote Link to comment Share on other sites More sharing options...
Fatalist Posted January 9, 2017 Share Posted January 9, 2017 You need the hitArea property: el.hitArea = new PIXI.Rectangle(0, 0, 100, 100); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.