Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to make self-writing dialogue?
Started by marcelopotty0 Nov 25 2018 09:31 PM

- - - - -
3 replies to this topic
string lua text dialogue

Best Answer XeduR @Spyric , 26 November 2018 - 12:57 AM

You just need to make a slight adjustment. I would also recommend that you assign custom anchorX and Y to the text so that it functions like in those other games you mentioned.

 

s = [[this is a multiline
texto en lua]]

local tam = string.len(s)

local cantidad  = 0

local displayed = display.newText("", 100, 100)
displayed.anchorX = 0
displayed.anchorY = 0

timer.performWithDelay(50, function()
	cantidad = cantidad+1
	displayed.text = s:sub(1,cantidad)
end, tam)

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

marcelopotty0

[GLOBAL: userInfoPane.html]
marcelopotty0
  • Observer

  • 11 posts
  • Corona SDK

I want the text to show in self-writing, like in Pokemon, Undertale, or any other game, but I have no idea of how to use the string functions to make it.

example:

 

texto = "hello"

"h"

"he"

"hel"

"hell"

"hello"

 

how can I do it?



[TOPIC: post.html]
#2

marcelopotty0

[GLOBAL: userInfoPane.html]
marcelopotty0
  • Observer

  • 11 posts
  • Corona SDK

s = [[this is a multiline
texto en lua]]
 
local tam = string.len(s)
 
local cantidad  = 0
 
local displayed = display.newText("", 100, 100)
--string.reverse(s)
 
timer.performWithDelay(50, function() cantidad = cantidad+1
 displayed.text = s:sub(tam-cantidad, tam) 
 end, tam)
 
 
 
--I tried this but the text is written from end to start, and not viceversa


[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 368 posts
  • Corona SDK

  Best Answer

You just need to make a slight adjustment. I would also recommend that you assign custom anchorX and Y to the text so that it functions like in those other games you mentioned.

 

s = [[this is a multiline
texto en lua]]

local tam = string.len(s)

local cantidad  = 0

local displayed = display.newText("", 100, 100)
displayed.anchorX = 0
displayed.anchorY = 0

timer.performWithDelay(50, function()
	cantidad = cantidad+1
	displayed.text = s:sub(1,cantidad)
end, tam)


[TOPIC: post.html]
#4

marcelopotty0

[GLOBAL: userInfoPane.html]
marcelopotty0
  • Observer

  • 11 posts
  • Corona SDK

Thank you so much!!! :D




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: string, lua, text, dialogue