Hi guys,
Ok I have yet another issue. I am using Mathew analog joystick (amazing piece of code!) and for the most part it works beautifully. I am trying to move a gun cross around the screen (Droid) using the joystick. I tried the following methods below.
The second method seems to be the best one (smoother) but there is a problem. If I stop moving my finger the gunCross keep moving (normal since there is deviation) I think it is probably because the joystick.lua do not return joyX =0 and joyY = 0 when the finger stop moving and there is deviation (joystick not at zero) I assume this but I am just newbie so do take this with a grain of salt…
I guess what I am after is a gunCross that moves smoothly with the joystick but stops when I stop moving my finger. By the way method 1 below work but is not very smooth and so not workable.
Hope someone call help with some pointers.
Thanks!
Mo.
ps: both methods are inside the “enterFrame” main()
-- METHOD 1
local function moveGunCross1(event)
if event.joyX ~= false then gunCross.x = screenW\*0.5 + event.joyX\*screenW\*0.5
if event.joyY ~= false then gunCross.y = screenH\*0.5 + event.joyY\*screenH\*0.5
....
end
-- METHOD 2
local function moveGunCross2(event)
if event.joyX ~= false then gunCross.x = gunCross.x + event.joyX\*5
if event.joyY ~= false then gunCross.y = gunCross.y + event.joyY\*5
.....
end
[import]uid: 49236 topic_id: 10350 reply_id: 310350[/import]