Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mousemove Events #57

Closed
englercj opened this issue Apr 9, 2013 · 9 comments
Closed

Mousemove Events #57

englercj opened this issue Apr 9, 2013 · 9 comments

Comments

@englercj
Copy link
Member

englercj commented Apr 9, 2013

Looks like we get mouseup, mousedown, mouseover, and mouseout events called on Sprites (per the docs). I want to allow dragging in grapefruit, is there anyway we can also get mousemove events so I can drag stuff around?

@Harissa
Copy link

Harissa commented Apr 9, 2013

This would be useful for me too. I had a look at the Interaction Manager code and it seems to be trapping mouse move but using it for mouse over and I'm not sure how to get a mouse move event. Any pointers would be great.

@GoodBoyDigital
Copy link
Member

cool, will rustle up an example :D

@dooprod
Copy link

dooprod commented Apr 15, 2013

Hi there! Just to bump this! I saw that too, in the Interaction Manager "mousemove" and even "hittest". This would be perfect if we can just call "mousemove" on any sprite and + a hittest method to have full interaction with our content! Right now I use a custom way based on updateHandler + mouseup / down event, not very clean!
PixiJS is a very cool engine! Very fun to build stuff! Thanks for your work!

@GoodBoyDigital
Copy link
Member

no worries! re-working a few bits on the interaction manger as we speak :)
Nearly finished too!

heres the WIP multi touch example:

http://www.goodboydigital.com/pixijs/examples/temp_6/

works great on an ipad..

I'm basically adding a few more bits:

Some new callbacks:

mousemove
mouseupoutside

touchendoutside
touchmove

I also added getLocalPosition function to the interactionData. This means you can get the cords of a touch/mouse from anywhere..

and most importantly I have been looking into making any object interactive :)

keen to know anyones thoughts on this! (you can view the src code in the example above to see how it would work)

Thanks!

@mud
Copy link

mud commented Apr 15, 2013

Yes, this is great!

@GoodBoyDigital
Copy link
Member

woop woop!! I have just pushed the updated interaction manager up along with docs and new example.
let me know if it works ok for you guys! :D

@dooprod
Copy link

dooprod commented Apr 16, 2013

It's perfect! Thank you! Now we can fully interact with our content ;-) !
And, just to go to the end of this topic: does anyone know how to implement a simple hitTest for PixiJS?

if ( hitTest( objectA, objectB ) ) console.log( "Woot!" );

I have a custom method to calculate lengh between 2 points like:

function hitTest( a, b ) {
  var dX = b.position.x - a.position.x;
  var dY = b.position.y - a.position.y;
  var dist = Math.sqrt( dX * dX - dY * dY );
  return dist <= a.width / 2 + b.width / 2;
}

// blabla --

Doesn't work everytime, and not very elegant! And I saw "PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)" in InteractionManager.as, so maybe we can start from that?

Thanks again!
PIXI-TIIIIME

@GoodBoyDigital
Copy link
Member

Excellent :D

The interactionManager hit test only performs a hittest on a single point so it may not be what you are looking for :/
Hit testing with non rotated rectangles is fairly straight forward process. It does get a little trickier once they are rotated though. Using SAT (Separating Axis Theorem) would be a good way of detecting any intersections.. but i'm sure there must be a simpler way if they are both rectangles..

Gonna close this thread now that all the mouse events are in!

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants