Users can enter accounts and passwords. Currently, editbox is used to enter user names and passwords. However, this is a common function of this commercial project, but no tutorials are found online, the Code is as follows:
Function MainScene: ctor ()
Ui. newTTFLabel ({text = "User Login", size = 20, align = ui. TEXT_ALIGN_CENTER })
: Pos (display. cx, display. cy + 50)
: AddTo (self)
------
Local function onEdit (event, editbox)
If event = "began" then
-- Start Input
Elseif event = "changed" then
-- The content of the input box changes.
Elseif event = "ended" then
-- Input ends
Elseif event = "return" then
-- Return from input box
End
End
Local editbox = ui. newEditBox ({
Image = "EditBox.png ",
Listener = onEdit,
Size = CCSize (200, 40)
})
Editbox: pos (display. cx, display. cy)
Editbox: addTo (self)
--------
Local editbox2 = ui. newEditBox ({
Image = "EditBox.png ",
Listener = onEdit,
Size = CCSize (200, 40)
})
-- Set the password input box
Editbox2: setInputFlag (0)
Editbox2: pos (display. cx, display. cy/2)
Editbox2: addTo (self)
--------------
EndsetInputFlag (0) is a real-time password input editbox.png to be made into a small image, and then the nine style is used to stretch without deformation