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

Centralize all input handling in FlxG.input #199

Open
Dovyski opened this issue Dec 27, 2013 · 2 comments
Open

Centralize all input handling in FlxG.input #199

Dovyski opened this issue Dec 27, 2013 · 2 comments

Comments

@Dovyski
Copy link
Member

Dovyski commented Dec 27, 2013

When Flixel was created, developers usually focused on a single platform. That's not the case anymore: games are targeting different platforms, e.g. mobile, console, pc, web, etc.

In order to simplify the input handling process, the idea is to create FlxG.input. It will be responsible for providing methods to read any type of input, e.g.:

FlxG.input.mouse.show();

if(FlxG.input.keys.any()) {
}

if(FlxG.input.fingers.any()) {
}

if(FlxG.input.fingers[0].x < 10 && FlxG.input.fingers[1].y > 50) {
}

if(FlxG.input.gamepad.justPressed("A")) {
}

@Gama11
Copy link

Gama11 commented Dec 27, 2013

I don't like this idea, it seems to bloat the code size for no reason at all. Yes, FlxG is a giant mess, but if you are going to screw over backwards compatibility like this anyway, you might as well create a new FlxInput class. Personally, I prefer the way HaxeFlixel does it though:

FlxG.keyboard
FlxG.mouse
FlxG.keys
FlxG.touches
FlxG.gamepads
FlxG.android

There are tons of possibilities to clean up FlxG in other ways (again, see HaxeFlixel).

@WingEraser
Copy link

FlxG will be fine after the clean up #142.

I wouldn't do FlxG.input, or do as @Gama11 says FlxInput.

flixel-gdx https://gi1thub.com/flixel-gdx/flixel-gdx/blob/master/flixel-core/src/org/flixel/FlxG.java
only got two FlxG.mouse and FlxG.keys. Mouse handles also the touches from mobile devices, so you won't need to type FlxG.mouse.justPressed and FlxG.touch.justPressed. It works for multi-touch as well.
The Gamepad is currently a plugin and I think it will stay like that.

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

No branches or pull requests

3 participants