Analogue Joystick - Sample Code WIP

this is my code at this point

[lua]local movePlayer = function()

xMotion = joystick.joyX
yMotion = joystick.joyY
if xMotion ~= false and yMotion ~= false then
xMotion = xMotion * 125
yMotion = yMotion * 125
playerObject:setLinearVelocity( xMotion , yMotion)
elseif xMotion == false or yMotion == false then
playerObject:setLinearVelocity( 0 , 0)
elseif xMotion ~= false and yMotion ~= false and isRunning == true then
xMotion = xMotion * 175
yMotion = yMotion * 175
playerObject:setLinearVelocity( xMotion , yMotion)
end
end

Runtime:addEventListener(“enterFrame”, movePlayer )

local makeRun = function( event )

if event.phase == “press” and event.id == “runbutton” then
isRunning = true

elseif event.phase == “release” and event.id == “runbutton” then
isRunning = false

end
end

local runBtn = ui.newButton{
default = “arrow.png”,
onEvent = makeRun,
id = “runbutton”
}
runBtn.x = midX + 100
runBtn.y = midY + 100[/lua] [import]uid: 19620 topic_id: 1632 reply_id: 56297[/import]

nevermind, my code above works, just needed to add isRunning == false to the first if statement, thanks again [import]uid: 19620 topic_id: 1632 reply_id: 56301[/import]

*deleted* [import]uid: 72520 topic_id: 1632 reply_id: 92405[/import]

Hi Matt,
this is very good indeed, thankyou.

problems all solved . [import]uid: 127675 topic_id: 1632 reply_id: 120115[/import]

Hi Matt,
this is very good indeed, thankyou.

problems all solved . [import]uid: 127675 topic_id: 1632 reply_id: 120115[/import]