here is my code if it helps, it’s line 74
local widget = require( "widget" ) local speedField = native.newTextField( 160, 450 , 150, 30 ) --------------------------------------------------------------------------------- -- main.lua --------------------------------------------------------------------------------- local speedText = display.newText(" ", 160, 18, native.systemFont, 16 ) -- function to handle button events local function handleButtonEvent( event ) if ( "ended" == event.phase ) then print ( "Speed = " .. tonumber(speedField.text) \* 2.55 ) if speedField.text == "" then local alert = native.showAlert( "Error", "No value entered" ) elseif tonumber(speedField.text) == nil then local alert = native.showAlert( "Error", "Must be a number" ) elseif tonumber(speedField.text) \> 100 then local alert = native.showAlert( "Error", "Speed must be inbetween 1 and 100" ) elseif tonumber(speedField.text) \< 1 then local alert = native.showAlert( "Error", "Speed must be inbetween 1 and 100" ) else speedText.text = (tonumber (speedField.text) \* 2.55) end end end -- create the widget local button = widget.newButton( { left = 70, top = 460, id = "button", label = "Continue", onEvent = handleButtonEvent } ) local directionText = display.newText( " ", 160, -10, native.systemFontBold, 18 ) -- Create function for stop button local function displayStop() local StopButton = display.newImage("stop.png") StopButton.x = display.contentCenterX StopButton.y = display.contentCenterY StopButton.xScale = 0.5 StopButton.yScale = 0.5 function StopButton:touch (event) if ( event.phase == "ended" ) then print("#CS") directionText.text = "Stop" end return true end StopButton:addEventListener("touch", StopButton) end local function addArrows( fullw, fullh, centerX, centerY, rotatione, command, code) local arrow = display.newImage("arrow.png") arrow.x = fullw arrow.y = fullh arrow.xScale = centerX arrow.yScale = centerY arrow.rotation = rotatione arrow.commande = command arrow.codee = code function arrow:touch (event) if ( event.phase == "ended" ) then print( code ) directionText.text = command end return true end arrow:addEventListener("touch", arrow) end -- local arrowE:addEventListener("touch", arrowE) local fullh = {160, 230, 260, 230, 160, 90, 60, 90} local fullw = {140, 170, 240, 310, 340, 310, 240, 170} local centerX = {0.30, 0.30, 0.30, 0.30, 0.30, 0.30, 0.30, 0.30} local centerY = {0.30, 0.30, 0.30, 0.30, 0.30, 0.30, 0.30, 0.30} local rotatione = {0, 45, 90, 135, 180, 225, 270, 315, 360} local command = {"Forward", "Right Forward", "Hard Right", "Right Backward", "Backward", "Left Backward", "Hard Left", "Left Forward"} local code = {CF, CRF, CHR, CRB, CB, CLB, CHL, CLF} for i = 1, #fullh do addArrows( fullh[i], fullw[i], centerX[i], centerY[i], rotatione[i], command[i], code[i] ) end displayStop()