Sprite movement interface

I have been considering the best way to move a character sprite around the screen.
The character is a bird.
I came to the conclusion it would be appropriate in my game to use a type of d pad in the bottom left of the screen.
I have looked at peaches d-pad tut and this seems nearly what I’am after.

However I would like to move in all axis’ not just at 90 degrees up/down/left and right. It has to be smooth.
Imagine being able to move a sprite on all areas of the screen via the control, the control will be a 50% alpha circle/orb graphic.
Anybody able to help with suggestions or sample code would be appreciated.

thanks [import]uid: 127675 topic_id: 29941 reply_id: 329941[/import]

if circle is at centx, centy, during the touch event calculate the angle between your touch and the center (in radians):

local angle = math.atan2( centy-event.y, event.x-centx)

or in degrees:

local angle = math.atan2( centy-event.y, event.x-centx)*180/math.pi

and distance from center:

local dist=math.sqrt((centx-event.x)*(centx-event.x)+(centy-event.y)*(centy-event.y))

and then do the game action accordingly.
[import]uid: 160496 topic_id: 29941 reply_id: 120089[/import]

@mike

thanks for that.

I have just stumbled across the analogue joystick routine posted a while ago, I think this may well solve the question. [import]uid: 127675 topic_id: 29941 reply_id: 120101[/import]

if circle is at centx, centy, during the touch event calculate the angle between your touch and the center (in radians):

local angle = math.atan2( centy-event.y, event.x-centx)

or in degrees:

local angle = math.atan2( centy-event.y, event.x-centx)*180/math.pi

and distance from center:

local dist=math.sqrt((centx-event.x)*(centx-event.x)+(centy-event.y)*(centy-event.y))

and then do the game action accordingly.
[import]uid: 160496 topic_id: 29941 reply_id: 120089[/import]

@mike

thanks for that.

I have just stumbled across the analogue joystick routine posted a while ago, I think this may well solve the question. [import]uid: 127675 topic_id: 29941 reply_id: 120101[/import]