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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.