Joystick / Joypad in Flash
Monday, April 14th, 2008I’ve always wanted to use a Joytick with my Flash games.
A while ago I was working on small game for Lorial - in-store advertising for Biotherm - through a great company Eness. It was a simple “catch the falling objects with a timelimit game” made in Flash, but needeed to be controlled using a joytick as it had to be simple and easy to use for anyone walking through Myer.
After a little research I found the amazing program AutoHotKey. This lets you specify macros to do things like using a joystick as a mouse or keys, or pressing a combination of keys and starting a program. Using this amazing peice of software (Windows only sorry) and hacking around with some of their joystick input exampels it was easy to map joystick movements and buttons to the arrow keys and “A” on the keyboard, which were then read by Flash.
On a recent game I’ve been working on (Scarygirl) I’ve found that user testing on the keyboard really gets in the way of the gameplay itself, especially for those not used to games. It was a lot easier to hand them a Playstation 2 DualShock controlller attached via a USB converter and have an AutoHotKey script running that converted the D-Pad and buttons to input. The hardest part of this is finding which button on the controller relates to what input into windows. The easiest way I found to work with this was Start->Control Panel->Controllers and just writing down a list of buttons as I pressed them.
So yeah. Easy. And fun. Some games are just so much better with a good controller - just never let me catch you playing an FPS on a console!