所以我正在 LibGDX (Kotlin) 中构建游戏并尝试设置用户名和密码字段。
我创建了我的 TextField
password = TextField("", Gui.skin)
我设置
password.isPasswordMode = true (Kotin changes setter and getters, under the hode this is calling setPasswordMode)
但是,当我在框中输入文本时,该文本仍会出现。我正在使用 LibGDX 1.9.6
最佳答案
setPasswordMode
将启用文本字段的密码显示模式。
它的工作原理是用预定义的字符替换每个字符。
默认情况下,这是项目符号“•”,某些字体可能没有。
将密码字符更改为您的字体具有的其他字符,例如“*”:
password.setPasswordCharacter('*')
请注意,您不能这样做
password.passwordCharacter = '*'
因为没有对应的
getPasswordCharacter
方法,因此不会生成 Kotlin 属性。
关于LIBGDX : setPasswordMode not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47750113/