I have to click on the sensor twice before it shows. I pulled out the following code that is not working as I expected. I’m sure its something simple I am doing wrong. Please help thanks
–> Define our touch event listener (my diagnostic cod is included (the function does not execute first time I —> click. It shows it was hit twice the second time I click.
function TrustSensor(event)
Touched = Touched + 1.0
yImage = display.newImage( “buttonBlue.png”, 0, 420, true )
msg = display.newText(“Touc1”, 10, 425, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
testtext2 = tostring (Touched, “%d”)
msg = display.newText( testtext2, 120, 425, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
if Fuel < 1 then
Trust = 0
Fuel = 0
else
Trust = Trust + 30
if Trust > 100 then
Trust = 100
end
yImage = display.newImage( “buttonBlue.png”, 0, 320, true )
msg = display.newText(“Touch”, 10, 325, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
testtext2 = tostring (Touched, “%d”)
msg = display.newText( testtext2, 120, 325, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
–> Display Trust Data
yImage = display.newImage( “buttonBlue.png”, 0, 120, true )
msg = display.newText(“Trust”, 10, 125, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
testtext2 = tostring (Trust, “%d”)
msg = display.newText( testtext2, 120, 125, native.systemFont, 30 )
msg:setTextColor( 255,255,255 )
end
end
–> Add trustcontrol
local trustcontrol = display.newImage(“TrustControl.png”)
trustcontrol.x = display.contentWidth -20
trustcontrol.y = display.contentHeight - 900
–> Turn Trust Control into physics body
physics.addBody(trustcontrol, { density=1, friction=10, bounce=.01 })
trustcontrol:addEventListener(“touch”, TrustSensor)
[import]uid: 12141 topic_id: 4702 reply_id: 304702[/import]