I’m having a problem making the transitions of some texts, I want that when I start writing in a textfield the word goes away, but this seems to double because it’s as if one remained static and the other if I made the transition, it is clear that these They are in a function, I do not know if that influences something. Thank you.
You should post the accompanying code so that people will have easier time helping you out.
function main()
newGroup=display.newGroup()
newGroupText=display.newGroup()
--cuadro text usuario
usuario=native.newTextField(0, 0,400, 60)
usuario.x=limites.left()+260.16
usuario.height=55
usuario.y=line1.y-25
usuario.setStrokeColor = {0,0,0}
usuario.id=“usuario”
usuario:setTextColor(0,0,0)
usuario.font=native.newFont(“SairaCondensed-Regular”)
usuario:addEventListener(“userInput”, fieldHandler(function() return usuario end ))
usuario.hasBackground=false
newGroupText:insert(usuario)
–cuadro texto contraseña
password=native.newTextField(0, 0, 400,60)
password.x=limites.left()+260.16
password.y=line2.y-25
password.height=55
password.isSecure=true
password:setTextColor(0,0,0)
password.id=“password”
password.font=native.newFont(“SairaCondensed-Regular”)
password:addEventListener(“userInput”, fieldHandler(function() return password end ))
password.hasBackground=false
newGroupText:insert(password)
–texto usuario
TextUser=display.newText(“Usuario o email”, 0, 0, “SairaCondensed-Regular”, 34)
TextUser:setFillColor(0,0,0)
TextUser.anchorX = 0
TextUser.x=usuario.x-usuario.width/2
TextUser.y=line1.y-20
newGroupText:insert(TextUser)
–texto contraseña
TextPassword=display.newText(“Contraseña”, 0, 0, “SairaCondensed-Regular”, 34)
TextPassword:setFillColor(0,0,0)
TextPassword.anchorX=0
TextPassword.x=password.x-password.width/2
TextPassword.y=line2.y-20
newGroupText:insert(TextPassword)
–Boton siguiente
Buttonnext=widget.newButton(
{
id=“siguiente”,
defaultFile=“Imagenes/botonsiguiente.png”,
overFile=“Imagenes/botonsiguiente.png”,
onEvent=handleButtonEvent
}
)
Buttonnext:scale(1,1)
Buttonnext.x=389
Buttonnext.y=limites.bottom()-280
newGroupText:insert(Buttonnext)
–Boton de olvido contraseña
ButtonOlvidar=widget.newButton(
{
id=“olvidar”,
defaultFile=“Imagenes/mensaje_cuenta.png”,
overFile=“Imagenes/mensaje_cuenta.png”,
onRelease=reestablecer
}
)
ButtonOlvidar:scale(0.7,0.7)
ButtonOlvidar.x=limites.right()-ButtonOlvidar.height/2-150
ButtonOlvidar.y=line2.y+25
newGroupText:insert(ButtonOlvidar)
newGroup:insert(newGroupText)
end
function reestablecer(event)
transition.moveTo(newGroupText,{x=limites.right()+200, limites.bottom()+300, time=0.1})
field_documento=native.newTextField(0, line1.y-25, 400,60)
field_documento.x=limites.left()+260.16
field_documento.hasBackground=false
field_documento:setTextColor(0,0,0)
field_documento.font=native.newFont(“SairaCondensed-Thin”)
field_documento.id=“field_documento”
field_documento.height=60
field_documento:addEventListener(“userInput”, fieldHandler(function () return field_documento end))
newGrouptransition:insert(field_documento)
Text_documento=display.newText(“Documento”, 0, field_documento.y, “SairaCondensed-Regular”, 34)
Text_documento.anchorX=0
Text_documento.x=field_documento.x-field_documento.width/2
Text_documento:setFillColor(0,0,0)
newGrouptransition:insert(Text_documento)
field_correo=native.newTextField(limites.left()+260.16, line2.y-25, 400, 60 )
field_correo.hasBackground=false
field_correo:setTextColor(0,0,0)
field_correo.id=“field_correo”
field_correo.height=60
field_correo.inputType=“email”
field_correo.font=native.newFont(“SairaCondensed-Thin”)
field_correo:addEventListener(“userInput”, fieldHandler(function () return field_correo end))
newGrouptransition:insert(field_correo)
Text_correo=display.newText(“Correo Electronico”, 0, field_correo.y, “SairaCondensed-Regular”, 34)
Text_correo.anchorX=0
Text_correo.x=field_documento.x-field_documento.width/2
Text_correo:setFillColor(0,0,0)
newGrouptransition:insert(Text_correo)
newButtonRegresar=widget.newButton{
id=“atras”,
defaultFile=“Imagenes/btn_cerrar_menu.png”,
overFile=“Imagenes/btn_cerrar_menu.png”,
onEvent=handleButtonEvent
}
newButtonRegresar.x=line1.x
newButtonRegresar:scale(1.5,1.5)
newButtonRegresar.y=limites.bottom()-newButtonRegresar.height/2-50
newGrouptransition:insert(newButtonRegresar)
btn_enviar=widget.newButton(
{
id=“btn_enviar”,
defaultFile=“Imagenes/btn_enviar.png”,
overFile=“Imagenes/btn_enviar.png”,
onEvent=handleButtonEvent
}
)
btn_enviar.x=display.contentCenterX
btn_enviar.width=Buttonnext.width
btn_enviar.y=limites.bottom()-280
newGrouptransition:insert(btn_enviar)
end
function fieldHandler(getObj)
return function(event)
if(event.phase==“began”)then
newRect:addEventListener(“tap”,listenerKeyboard)
newRect.alpha=0.5
print(“inicio”)
if(event.target.id==“field_documento”)then
transition.moveTo(Text_documento,{x=-100, y=-100, time=1})
elseif(event.target.id==“field_correo”)then
transition.moveTo(Text_correo,{x=-100, y=-100, time=1})
end
elseif(event.phase=="ended"or event.phase==“cancelled”)then
newRect:removeEventListener(“tap”,listenerKeyboard)
newRect.alpha=1
if(event.target.text=="" and event.target.id==“field_correo”)then
transition.moveTo(Text_correo,{x=usuario.x-usuario.width/2, y=line1.y-20, time=3})
elseif(event.target.text=="" and event.target.id==“field_documento”)then
transition.moveTo(Text_documento,{x=password.x-password.width/2, y=line2.y-20, time=3})
end
print(“termino”)
elseif(event.phase==“submitted”)then
listenerKeyboard()
end
end
end–
When posting code, please use the code formatting tools to make it easier to read.
Also, I reread your original post and I don’t really understand what you want to happen.
You seem to have have very brief transition times, i.e. 1 or 3 milliseconds. With transitions so fast, they cannot be perceived and it’d be easier to just change manually set the object’s x and y coordinates. But, instead of using those transitions to begin with, why not just turn the text completely transparent while you are editing it and then turn it visible again once you are done? That way you don’t need to worry about the text moving at all.
why not just turn the text completely transparent while you are editing it and then turn it visible again once you are done? how do that?
You turn an object transparent by
object.alpha = 0
and visible again by
object.alpha = 1
ok. thanks
You should post the accompanying code so that people will have easier time helping you out.
function main()
newGroup=display.newGroup()
newGroupText=display.newGroup()
--cuadro text usuario
usuario=native.newTextField(0, 0,400, 60)
usuario.x=limites.left()+260.16
usuario.height=55
usuario.y=line1.y-25
usuario.setStrokeColor = {0,0,0}
usuario.id=“usuario”
usuario:setTextColor(0,0,0)
usuario.font=native.newFont(“SairaCondensed-Regular”)
usuario:addEventListener(“userInput”, fieldHandler(function() return usuario end ))
usuario.hasBackground=false
newGroupText:insert(usuario)
–cuadro texto contraseña
password=native.newTextField(0, 0, 400,60)
password.x=limites.left()+260.16
password.y=line2.y-25
password.height=55
password.isSecure=true
password:setTextColor(0,0,0)
password.id=“password”
password.font=native.newFont(“SairaCondensed-Regular”)
password:addEventListener(“userInput”, fieldHandler(function() return password end ))
password.hasBackground=false
newGroupText:insert(password)
–texto usuario
TextUser=display.newText(“Usuario o email”, 0, 0, “SairaCondensed-Regular”, 34)
TextUser:setFillColor(0,0,0)
TextUser.anchorX = 0
TextUser.x=usuario.x-usuario.width/2
TextUser.y=line1.y-20
newGroupText:insert(TextUser)
–texto contraseña
TextPassword=display.newText(“Contraseña”, 0, 0, “SairaCondensed-Regular”, 34)
TextPassword:setFillColor(0,0,0)
TextPassword.anchorX=0
TextPassword.x=password.x-password.width/2
TextPassword.y=line2.y-20
newGroupText:insert(TextPassword)
–Boton siguiente
Buttonnext=widget.newButton(
{
id=“siguiente”,
defaultFile=“Imagenes/botonsiguiente.png”,
overFile=“Imagenes/botonsiguiente.png”,
onEvent=handleButtonEvent
}
)
Buttonnext:scale(1,1)
Buttonnext.x=389
Buttonnext.y=limites.bottom()-280
newGroupText:insert(Buttonnext)
–Boton de olvido contraseña
ButtonOlvidar=widget.newButton(
{
id=“olvidar”,
defaultFile=“Imagenes/mensaje_cuenta.png”,
overFile=“Imagenes/mensaje_cuenta.png”,
onRelease=reestablecer
}
)
ButtonOlvidar:scale(0.7,0.7)
ButtonOlvidar.x=limites.right()-ButtonOlvidar.height/2-150
ButtonOlvidar.y=line2.y+25
newGroupText:insert(ButtonOlvidar)
newGroup:insert(newGroupText)
end
function reestablecer(event)
transition.moveTo(newGroupText,{x=limites.right()+200, limites.bottom()+300, time=0.1})
field_documento=native.newTextField(0, line1.y-25, 400,60)
field_documento.x=limites.left()+260.16
field_documento.hasBackground=false
field_documento:setTextColor(0,0,0)
field_documento.font=native.newFont(“SairaCondensed-Thin”)
field_documento.id=“field_documento”
field_documento.height=60
field_documento:addEventListener(“userInput”, fieldHandler(function () return field_documento end))
newGrouptransition:insert(field_documento)
Text_documento=display.newText(“Documento”, 0, field_documento.y, “SairaCondensed-Regular”, 34)
Text_documento.anchorX=0
Text_documento.x=field_documento.x-field_documento.width/2
Text_documento:setFillColor(0,0,0)
newGrouptransition:insert(Text_documento)
field_correo=native.newTextField(limites.left()+260.16, line2.y-25, 400, 60 )
field_correo.hasBackground=false
field_correo:setTextColor(0,0,0)
field_correo.id=“field_correo”
field_correo.height=60
field_correo.inputType=“email”
field_correo.font=native.newFont(“SairaCondensed-Thin”)
field_correo:addEventListener(“userInput”, fieldHandler(function () return field_correo end))
newGrouptransition:insert(field_correo)
Text_correo=display.newText(“Correo Electronico”, 0, field_correo.y, “SairaCondensed-Regular”, 34)
Text_correo.anchorX=0
Text_correo.x=field_documento.x-field_documento.width/2
Text_correo:setFillColor(0,0,0)
newGrouptransition:insert(Text_correo)
newButtonRegresar=widget.newButton{
id=“atras”,
defaultFile=“Imagenes/btn_cerrar_menu.png”,
overFile=“Imagenes/btn_cerrar_menu.png”,
onEvent=handleButtonEvent
}
newButtonRegresar.x=line1.x
newButtonRegresar:scale(1.5,1.5)
newButtonRegresar.y=limites.bottom()-newButtonRegresar.height/2-50
newGrouptransition:insert(newButtonRegresar)
btn_enviar=widget.newButton(
{
id=“btn_enviar”,
defaultFile=“Imagenes/btn_enviar.png”,
overFile=“Imagenes/btn_enviar.png”,
onEvent=handleButtonEvent
}
)
btn_enviar.x=display.contentCenterX
btn_enviar.width=Buttonnext.width
btn_enviar.y=limites.bottom()-280
newGrouptransition:insert(btn_enviar)
end
function fieldHandler(getObj)
return function(event)
if(event.phase==“began”)then
newRect:addEventListener(“tap”,listenerKeyboard)
newRect.alpha=0.5
print(“inicio”)
if(event.target.id==“field_documento”)then
transition.moveTo(Text_documento,{x=-100, y=-100, time=1})
elseif(event.target.id==“field_correo”)then
transition.moveTo(Text_correo,{x=-100, y=-100, time=1})
end
elseif(event.phase=="ended"or event.phase==“cancelled”)then
newRect:removeEventListener(“tap”,listenerKeyboard)
newRect.alpha=1
if(event.target.text=="" and event.target.id==“field_correo”)then
transition.moveTo(Text_correo,{x=usuario.x-usuario.width/2, y=line1.y-20, time=3})
elseif(event.target.text=="" and event.target.id==“field_documento”)then
transition.moveTo(Text_documento,{x=password.x-password.width/2, y=line2.y-20, time=3})
end
print(“termino”)
elseif(event.phase==“submitted”)then
listenerKeyboard()
end
end
end–
When posting code, please use the code formatting tools to make it easier to read.
Also, I reread your original post and I don’t really understand what you want to happen.
You seem to have have very brief transition times, i.e. 1 or 3 milliseconds. With transitions so fast, they cannot be perceived and it’d be easier to just change manually set the object’s x and y coordinates. But, instead of using those transitions to begin with, why not just turn the text completely transparent while you are editing it and then turn it visible again once you are done? That way you don’t need to worry about the text moving at all.
why not just turn the text completely transparent while you are editing it and then turn it visible again once you are done? how do that?
You turn an object transparent by
object.alpha = 0
and visible again by
object.alpha = 1
ok. thanks