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

Mousemovement Performance improvement #1072

Open
Matt-Maerz opened this issue Apr 26, 2022 · 2 comments
Open

Mousemovement Performance improvement #1072

Matt-Maerz opened this issue Apr 26, 2022 · 2 comments

Comments

@Matt-Maerz
Copy link

Hello everyone,
I am looking for an alternative/better performing MouseMovement method.
I read the following in another entry:

#977
I do recommend writing your own hit testing if you don't need pixel perfect hit interactions though!

So I assume the problem is in the hitTest method, which analyzes pixel perfect everything.
I still dared to modify the CreateJS lib.
Does anyone here have experience and can help me how to adjust which method?
Thank you!

@danzen
Copy link
Contributor

danzen commented Sep 12, 2022

Hi @Matt-Maerz - you may want to check out the various hitTests in ZIM, a framework built on CreateJS. We do several types of hitTests that are not pixel based and even the pixel based ones we do a calculated bounds check first. May as well see if the bounds are hitting with an equation before testing pixels. This dramatically increases the efficiency of hitTests. ZIM is at https://zimjs.com and the tips page https://zimjs.com/tips.html#HITTEST. You can see the types of hitTests in the docs https://zimjs.com/docs.html under the methods section.
image

hitTestPoint() is the same as the CreateJS hitTest.
hitTestReg() same as above but tests against the registration point
hitTestBounds() is a fast calculation between bounds of objects
hitTestCircleRect() is a fast calculation between a circle and a rectangle
hitTestGrid() is a fast calculation for grid sections
hitTestRect() and hitTestCircle() test any shape against points around a rectangle or circle (slower as shape based)
etc.

@danzen
Copy link
Contributor

danzen commented Sep 12, 2022

Oh!!! Sorry, @Matt-Maerz - I just re-read the issue and it seems like you may have been talking about just rollovers in CreateJS using pixel based detection. Okay. I will leave the last response there in case you are wanting to do your own hitTests. We have been fine with mouseover speed in general and keep it turned on by default in ZIM. We then use mouseChildren and mouseEnabled false when objects do not need to be interacted with. We have simplified this with a mouse() and noMouse() methods available on all our DisplayObjects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants