ranom Posted May 14, 2015 Share Posted May 14, 2015 Trying to accomplish a very simple thing - get the x and y values of the current mouse coordinate. I found this method defined here http://www.goodboydigital.com/pixijs/docs/classes/Stage.html#method_getMousePositionHowever javascript console says: Uncaught TypeError: stage.getMousePosition is not a functionUsing the latest pixi build (as of 14.5.2015). Are the docs outdated or am i doing something wrong? Quote Link to comment Share on other sites More sharing options...
xerver Posted May 14, 2015 Share Posted May 14, 2015 Yes, you are looking at v2 documentation and using v3 of the library If you need the current mouse position you can get it from the interaction manager:var mousePosition = renderer.interaction.mouse.global; Quote Link to comment Share on other sites More sharing options...
ranom Posted May 14, 2015 Author Share Posted May 14, 2015 thanks! Quote Link to comment Share on other sites More sharing options...
ranom Posted May 14, 2015 Author Share Posted May 14, 2015 console.log(renderer.interaction) undefined I'm lost. Does a webpage for v3 docs exist? Perhaps i should try v2... Quote Link to comment Share on other sites More sharing options...
xerver Posted May 14, 2015 Share Posted May 14, 2015 Docs: http://pixijs.github.io/docs/ Can you show me an example of running code that doesn't have the "renderer.interaction" property? Because it definitely exists... Quote Link to comment Share on other sites More sharing options...
xerver Posted May 15, 2015 Share Posted May 15, 2015 God I'm so stupid, it is "renderer.plugins.interaction" not "renderer.interaction" so sorry about that!! Quote Link to comment Share on other sites More sharing options...
xdiepx Posted May 15, 2015 Share Posted May 15, 2015 God I'm so stupid, it is "renderer.plugins.interaction" not "renderer.interaction" so sorry about that!! if you was to make a drag or drop function, which one are u mostly likely to use?function onMove (e){ var mouseData = renderer.plugins.interaction.mouse.global;}orfunction onMove (e){ var mouseData = e.data.getLocalPosition(stageContainer);} Quote Link to comment Share on other sites More sharing options...
xerver Posted May 16, 2015 Share Posted May 16, 2015 For drag specifically I don't think it matters because all that matters is the delta between the moves, not what the point is when you check. Whichever feels best to you is probably good, getLocalPosition does involve some matrix calculations so *maybe* you want to avoid that if you don't *need* to know the exact local position? Quote Link to comment Share on other sites More sharing options...
xdiepx Posted May 16, 2015 Share Posted May 16, 2015 cool, thanks for the advice Quote Link to comment Share on other sites More sharing options...
topherlicious Posted December 30, 2022 Share Posted December 30, 2022 Hello, this method no longer works in version 7 since replacing InteractionManager with EventSystem. I haven't been able to find a new method for determining mouse position, is there a new method documented somewhere? I see that `rootPointerEvent` exists on `app.renderer.events` but it is not exposed, is there a standard way of accessing that? In TypeScript I can use... (app.renderer.events as any).rootPointerEvent.global ...for now which works, but I thought I'd ask if there's a better way to do this. Quote Link to comment Share on other sites More sharing options...
Czeers Posted January 4, 2023 Share Posted January 4, 2023 On 12/30/2022 at 7:05 PM, topherlicious said: Hello, this method no longer works in version 7 since replacing InteractionManager with EventSystem. I haven't been able to find a new method for determining mouse position, is there a new method documented somewhere? I see that `rootPointerEvent` exists on `app.renderer.events` but it is not exposed, is there a standard way of accessing that? In TypeScript I can use... (app.renderer.events as any).rootPointerEvent.global ...for now which works, but I thought I'd ask if there's a better way to do this. Hello, unfortunatelly this didn't work for me, i found the solution and then get coordinates from the event: app.renderer.view.onmousemove = function (e:any) { console.log(e) } i am not sure if this is the way it should be handled but it works Quote Link to comment Share on other sites More sharing options...
James Millere Posted January 5, 2023 Share Posted January 5, 2023 event.data.global try this, is a PIXI.Point with x/y properties that range from 0 to the size of the canvas. 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.