I have a problem, I need when I press the letter button, then in the center of the screen will be written the selected letter.
I want to make an idea of a word game part of which is to recognize the word, when the player selects a certain letter then the letter is seen on the screen and then slowly finish the word and the word is revealed.
Is it built correctly?
Or is there some way to do better there is room to read on the subject?
Attached below is the code
local selectOt = display.newText( “select key”,300,20, native.systemFont, 35 )
selectOt.x = display.contentCenterX
selectOt.y = display.contentCenterY*0.6
selectOt:setFillColor( 1, 0, 0 )
local keyboard_group = display.newGroup()
keyboard_group.alpha = 0
local keyboard_ot_1 = display.newText(“1”, display.contentCenterX, display.contentCenterY, system.nativeFont, 25)
keyboard_ot_1:setFillColor(1, 0, 0)
keyboard_ot_1.text = “a”
keyboard_ot_1.x = display.contentCenterX1.72
keyboard_ot_1.y = display.contentCenterY1.67
keyboard_group:insert(keyboard_ot_1)
local keyboard_ot_2 = display.newText(“2”, display.contentCenterX, display.contentCenterY, system.nativeFont, 25)
keyboard_ot_2:setFillColor(1, 0, 0)
keyboard_ot_2.text = “b”
keyboard_ot_2.x = display.contentCenterX1.52
keyboard_ot_2.y = display.contentCenterY1.67
keyboard_group:insert(keyboard_ot_2)
local keyboard_ot_3 = display.newText(“3”, display.contentCenterX, display.contentCenterY, system.nativeFont, 25)
keyboard_ot_3:setFillColor(1, 0, 0)
keyboard_ot_3.text = “c”
keyboard_ot_3.x = display.contentCenterX1.32
keyboard_ot_3.y = display.contentCenterY1.67
keyboard_group:insert(keyboard_ot_3)
local keyboard_ot_4 = display.newText(“4”, display.contentCenterX, display.contentCenterY, system.nativeFont, 25)
keyboard_ot_4:setFillColor(1, 0, 0)
keyboard_ot_4.text = “d”
keyboard_ot_4.x = display.contentCenterX1.12
keyboard_ot_4.y = display.contentCenterY1.67
keyboard_group:insert(keyboard_ot_4)
keyboard_group.anchorChildren = true
keyboard_group.anchorX = 0.5
keyboard_group.x = display.contentCenterX
keyboard_group.y = display.contentCenterY*1.835
keyboard_group.alpha = 0
transition.to(keyboard_group, {time = 800, alpha = 1})
local playkeyboard = true
function playkeyboard (event)
if (keyboard_ot_1.text == “a”) then
print(“a”)
selectOt.text = “a”
elseif (keyboard_ot_2.text == “b”) then
print(“b”)
selectOt.text = “b”
elseif (keyboard_ot_3.text == “c”) then
print(“c”)
selectOt.text = “c”
elseif (keyboard_ot_4.text == “d”) then
print(“d”)
selectOt.text = “d”
else
print(“but sad”)
end
end
—keyboard_ot_1:addEventListener(“tap”,playkeyboard)
–keyboard_ot_2:addEventListener(“tap”,playkeyboard)
–keyboard_ot_3:addEventListener(“tap”,playkeyboard)
–keyboard_ot_4:addEventListener(“tap”,playkeyboard)
keyboard_group:addEventListener(“tap”,playkeyboard)