-- Tonumber
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
redColor = 255
end
function draw()
background(40, 40, 50)
fill(redColor,255,0,255)
nbr=keyboardBuffer()
if not nbr == nil then
redColor=tonumber(nbr)
end
text("Hello World! WOLOLO",600,600)
strokeWidth(5)
end
function touched(touch)
if touch.state == ENDED then
showKeyboard()
end
end
I’m trying to make the redColor variable accept a number value from the keyboard. Since keyboardBuffer only makes strings and fill only takes numbers I try to convert it with tonumber()
My code doesn’t work.