FlixelCommunity / flixel

Community fork of Adam “Atomic” Saltsman's popular game engine Flixel. Distilled from a variety of Flash games he worked on over the last couple years, including Gravity Hook, Fathom and Canabalt, its primary function is to provide some useful base classes that you can extend to make your own game objects.
http://flixelcommunity.org/
Other
84 stars 17 forks source link

Centralize all input handling in FlxG.input #199

Open Dovyski opened 10 years ago

Dovyski commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

FlxG will be fine after the clean up https://github.com/FlixelCommunity/flixel/issues/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.