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

FlxMouseEventManager doesn't play nice with substates #1972

Closed
Tracked by #2538
Gama11 opened this issue Oct 3, 2016 · 2 comments
Closed
Tracked by #2538

FlxMouseEventManager doesn't play nice with substates #1972

Gama11 opened this issue Oct 3, 2016 · 2 comments
Milestone

Comments

@Gama11
Copy link
Member

Gama11 commented Oct 3, 2016

This is essentially the same issue as #1087 (which was resolved in #1934) but for FlxMouseEventManager.

A fix was proposed in #1961, but in my opinion it breaks too much code to be considered before a major version (5.0.0). Maybe there's a way of fixing this without breaking much code though?

@Geokureli
Copy link
Member

Geokureli commented Apr 22, 2022

this isn't a class I use very much, but I have some ideas after applying these changes to a local branch (this branch is outdated, so I made the changes manually).

With this proposed changes existing games will need to change all refs such as

FlxMouseEventManager.add(obj, onDown, null, onOver, onOut)
// becomes
FlxMouseEventManager.globalManager.add(obj, onDown, null, onOver, onOut)

While it works with surprsingly minimal changes to all HF libs, that's pretty verbose and cumbersome for devs. for cleaner code, what if we rename ObjectMouseData to FlxMouseEvent (or FlxTypedMouseEvent<T> and a typedef) and change the standard utilization to:

new FlxMouseEvent(obj, onDown, null, onOver, onOut)
// or
FlxMouseEvent.manage(obj, onDown, null, onOver, onOut)
// or
FlxMouseEvent.create(obj, onDown, null, onOver, onOut)
// or
FlxMouseEvent.track(obj, onDown, null, onOver, onOut)

We would also add a final manager arg, which defaults to the global manager. This is based on how FlxTween and FlxTimer work

Alternatively, we could recreate all the the old static functions of FlxMouseEventManager and create FlxMouseEvent.add and remove and the like, with the added manager arg

Option 3: we add FlxG.mouse.events or FlxG.mouseEvents and set it to the globalManager

@Geokureli
Copy link
Member

Geokureli commented Apr 23, 2022

I've made my proposed changes in #2540

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