Skip to content

Mousemovement Performance improvement #1072

Open

Description

@Matt-Maerz

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!

Activity

  1. danzen commented on Sep 12, 2022

    @danzen
    Contributor

    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.

  2. danzen commented on Sep 12, 2022

    @danzen
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions