Quick-cocos2d-x tutorial 12: Implementing the text and Password Input Interface

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.