如何在 Corona SDK 中更改 TextField(本机库)的可见性,即使其不可见
How to change the visibility of a TextField (native library), i.e. make it invisible, in Corona SDK
是否可以使 TextField
(对于 Corona SDK native
库)不可见?如果是这样,那又如何呢? isVisible
属性 好像不行。
例如,如果我像这样创建一个 TextField
实例:
local textIngrediente1 = native.newTextField(...)
当我尝试通过像这样设置 isVisible
属性 使其不可见时:
textIngredient1.isVisible = false
它对 TextField
的可见性没有影响。
您不能使用 isVisible 和 alpha 属性,显示对象除外。
但是您可以将 textField 设置为离开屏幕,然后在需要显示 textField 时更改 x,y 坐标..
local text= native.newTextField( ... )
text.x = -100
text.y = -100
然后当您需要使用或显示 textField 对象时
text.x = 100
text.y = 100
我认为这会成功
native.newTextField() 确实尊重 .isVisible 属性。我刚刚测试了它。如果您复制并粘贴您的代码,您可能会遇到错误:
--local textIngrediente1 = native.newTextField(...)
-- textIngredient1.isVisible = false
其中一个你使用 textIngrediente1
在另一个中,您使用 textIngredient1(没有额外的 e)
根据 Corona 文档,TextField
objects inherit properties from NativeDisplayObjects
which inherit properties from DisplayObjects
, including the isVisible
property,所以(只要没有拼写错误 ;-))这个 将 控制 TextField
.
是否可以使 TextField
(对于 Corona SDK native
库)不可见?如果是这样,那又如何呢? isVisible
属性 好像不行。
例如,如果我像这样创建一个 TextField
实例:
local textIngrediente1 = native.newTextField(...)
当我尝试通过像这样设置 isVisible
属性 使其不可见时:
textIngredient1.isVisible = false
它对 TextField
的可见性没有影响。
您不能使用 isVisible 和 alpha 属性,显示对象除外。 但是您可以将 textField 设置为离开屏幕,然后在需要显示 textField 时更改 x,y 坐标..
local text= native.newTextField( ... )
text.x = -100
text.y = -100
然后当您需要使用或显示 textField 对象时
text.x = 100
text.y = 100
我认为这会成功
native.newTextField() 确实尊重 .isVisible 属性。我刚刚测试了它。如果您复制并粘贴您的代码,您可能会遇到错误:
--local textIngrediente1 = native.newTextField(...)
-- textIngredient1.isVisible = false
其中一个你使用 textIngrediente1 在另一个中,您使用 textIngredient1(没有额外的 e)
根据 Corona 文档,TextField
objects inherit properties from NativeDisplayObjects
which inherit properties from DisplayObjects
, including the isVisible
property,所以(只要没有拼写错误 ;-))这个 将 控制 TextField
.