Hey Guys
Im working on an Analogue Joystick, for use with the game edition most probably. I will post the finished item in the Sample Code area but I though I would get your feedback first.
This v1.0 demo shows it working with a quick top down scrolling shooter style game I mocked up to get visual feedback on the output of the control.
Get it here http://www.alienhorde.com/files/joystick_1_0.zip
Ignore the plane.lua / background.lua / sprite.lua / main.lua, the code we are looking at is in joystick.lua
Its my aim that you include the joystick file
local joystick = require( "joystick" )
You initialise the joystick, passing it 2 files for the outer and inner joystick elements, alpha and position
joystick.loadJoystick( "joystickOuter.png", 0.75 , "joystickInner.png", 0.75 , 15 , 345 )
The code will then setup the joystick and all other elements ( I still need to include a stop / start and a reorientation for landscape)
You can then, from anywhere in the code, in main.lua or any other included files query the following
joyVector ( returns 0 to 1 )
joyAngle ( returns full 360 degrees, 0 pointing up and degrees increasing clockwise )
joyX ( -1 to 1 )
joyY ( -1 to 1 )
Each attribute returns false when the joystick is not in use.
I have left a “Ghost” on the screen that will follow the touch, I track the touch past the boundaries of the outer joystick market but I limit the values to 1 at the marker limit. This just allows the user to retain control even if they accidentally drag outside of the joystick.
The joystick currently points to where the touch currently is, this wont be in the final release and it just for testing of orientations.
[import]uid: 5354 topic_id: 1632 reply_id: 301632[/import]