lunarovich Posted May 7, 2015 Share Posted May 7, 2015 Hello, in pixi.js V2 I was using getMousePosition() of the Stage class to read a mouse position in every frame. In V3, the Stage class is gone, together with its getMousePosition(). Now, in V3, I know that InteractionManager has a property .mouse, which is of the type InteractionData. However, I do not know how to grab a reference to the automatically created instance of the InteractionManager. On the other hand, if I try to instantiate the InteractionManager myself, I can read a global mouse position. However, all the mouse events are reported twice, which is unacceptable... Lastly, there is no callback possibility for .mousemove on regular DisplayObjects/Containers, so I cannot read the interactionData in every tick. Quote Link to comment Share on other sites More sharing options...
xerver Posted May 7, 2015 Share Posted May 7, 2015 renderer.plugins.interaction That is the interaction manager that is already created for you. Quote Link to comment Share on other sites More sharing options...
jcdiprose Posted May 7, 2015 Share Posted May 7, 2015 code snippets is helpful to allow other people to help you.. I have used a mousemove event listener on a sprite like this..mySprite('mousemove', mouseMoveCallback);function mouseMoveCallback(mouseData) { console.log("X = "+mouseData.data.originalEvent.movementX); console.log("Y = "+mouseData.data.originalEvent.movementY);}This is correct syntax for V3 and will log your mouse position in the console. You still create a 'stage' of sorts with the code..//you can therefore use the listener on the stage variablevar stage = new PIXI.Container(0xFFFFFF);I have yet to discover the necessity of the Interaction Manager class as my app is interactive without instantiating it. Hope this helps! Wesley W 1 Quote Link to comment Share on other sites More sharing options...
xerver Posted May 7, 2015 Share Posted May 7, 2015 I think you meant: mySprite.on('mousemove', ...); And you should pass color to the renderer (backgroundColor option), not the container. Passing color to a container does nothing. I have yet to discover the necessity of the Interaction Manager class as my app is interactive without instantiating it. That is because we create one for you, and it is exposed at "renderer.plugins.interaction". Quote Link to comment Share on other sites More sharing options...
lunarovich Posted May 8, 2015 Author Share Posted May 8, 2015 Thank you very much. Evertything works just fine now. Quote Link to comment Share on other sites More sharing options...
systemx17 Posted May 9, 2015 Share Posted May 9, 2015 Lunarovich, can you mark this as answered as it might help others too. Quote Link to comment Share on other sites More sharing options...
Wesley W Posted January 19, 2016 Share Posted January 19, 2016 On 5/7/2015 at 10:14 PM, jcdiprose said: mySprite('mousemove', mouseMoveCallback);function mouseMoveCallback(mouseData) { console.log("X = "+mouseData.data.originalEvent.movementX); console.log("Y = "+mouseData.data.originalEvent.movementY);} the movementX & movementY params isn't works for me on chrome(v 47.0.2526.111). i use pageX pageY instead of. the codes such like: mouseData.data.originalEvent.pageX mouseData.data.originalEvent.pageY hope this can help someone who need it. 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.