When it comes to tracking mouse events, is one method better than another?

0 favourites
  • 4 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I'm wondering if there's any benefit/efficiency to be had when using one central mouse-handling event, versus having separate mouse handlers for explicit events, controls, etc.

    In other words, is this...

    on mouseclick

    test for situation 1

    do something

    test for situation 2

    do something

    test for situation 3

    do something

    ...any better/more efficient than

    on mouseclick & situation 1

    do something

    on mouseclick & situation 2

    do something

    on mouseclick & situation 3

    do something

    I currently have a project set up using the former arrangement (one central mouse event handler) and it's becoming increasingly unwieldy and difficult to manage the code. So can I consider breaking up the handler into separate individual mouse events, or would it be bad to have, say, 20 separate mouseclick events all tracking the mouse at the same time?

    Thanks in advance for any enlightenment here.

    Tagged:

  • Those events suppose that all mouse clicks should be independent of the situations.

    The mouse clicks should be dependent on the situations.

  • "Situation" may be a poor word choice -- each mouse click event is taking place on separate controls and objects in a UI. Some of the controls trigger events, some of the controls trigger events but also trigger other controls, and some of the clicks occur on non-control objects in a layout.

    It's becoming increasingly difficult and messy to try to route all these events through a single mouse event handler, which is why I want to employ multiple mouse event handlers, unless there's some penalty/disadvantage for doing so.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • As with all optimization inquiries, if you can't measure a difference yourself, then you're probably wasting your time.

    On the other hand, organizing your events in a manner that is readable, easy to modify, and makes sense for you yourself to work with has a decidedly clear and immediate benefit, regardless of what others might consider best practice.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)