SarahJ

Event called when mouse is being pressed

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.