SarahJ Posted March 8, 2019 Share Posted March 8, 2019 Right now I'm using `interaction.on('mousedown', event => myFunction(event));` to detect when the mouse is first pressed down. However, I can't find out how to have a function called every frame is the mouse is still down. I've checked out the docs and it appears there is nothing to do so. Is there a built-in way to do this is Pixi.js, or do I have to use the Javascript ways to do this? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 8, 2019 Share Posted March 8, 2019 According to https://github.com/pixijs/pixi.js/blob/v4.x/src/interaction/interactiveTarget.js#L104 , there's internal "trackedPointers" (_trackedPointers) where you can get all the data about current mouse/pen/whatever that is interacting with the element. I dont remember more details, but I'm sure you can just look in console and debug it to see what values it returns. I remember that I used it in multiple projects. SarahJ 1 Quote Link to comment Share on other sites More sharing options...
SarahJ Posted March 9, 2019 Author Share Posted March 9, 2019 @ivan.popelyshev How would I use the canvas as an interactive target? For me, app.stage.trackedPointers returns an empty object. Do I have to bind it to the canvas somehow? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 9, 2019 Share Posted March 9, 2019 which object is interactive for you? Is your stage interactive=true? Also if you have only 10x10 sprite in stage, stage has size 10x10 pixels, its not whole screen. If you want mouse coords every , look at "app.renderer.plugins.interaction.mouse.global". Did you search for pointer/mouse/pen related issues in this forum and in pixijs issues? did you look at https://github.com/pixijs/pixi.js/wiki/v4-Gotchas ? If after everything that was said you stilll have no idea what to do, look at https://github.com/pixijs/pixi.js/blob/v4.x/src/interaction/InteractionManager.js#L993 . Source code allows you to skip my poor explanations and just hack whatever you want in interaction. Just place a breakpoint there and see where goes mousedown event. 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.