I have no errors. Try to close "console.lua" file and refresh project files (by right clicking on "Files" in project files section and hit "Refresh"). Open "console.lua" again and check if something changed.
-- then we set the layout: width, height, line spacing and justify center
textfield:setLayout({w=200, h=100, lineSpacing=7, flags=FontBase.TLF_CENTER})
Thank you very much for the great answers. Fixed it by creating a new project and copy pasting the exact same code. It's a bit strange but nevermind. By the way, here's my final code : a simple Texfield with typwriter effect and basic scroll function.
console = Core.class(Sprite)function console:init()local fnt = TTFont.new("Assets/cour.ttf", 20)
self.txt = TextField.new(fnt, nil)
self.txt:setLayout({w =300, flags=FontBase.TLF_LEFT})
self.txt:setAnchorPoint(0, 0)
self:addChild(self.txt)
self.allowType =true-- Simple scroll functionlocal z =nil
self:addEventListener(Event.MOUSE_DOWN, function(event)
z = event.y - self.txt:getY()end)
self:addEventListener(Event.MOUSE_MOVE, function(event)
self.txt:setY(event.y - z)end)endfunction console:tWrite(txtToPrint)if self.allowType then
self.allowType =falselocal i =1
self.txt:setText(self.txt:getText()..'\n')localfunction typeFunc()
self.txt:setText(self.txt:getText()..string.sub(txtToPrint, i, i))
i = i + 1if i >string.len(txtToPrint)then
self.allowType =true
self:removeEventListener(Event.ENTER_FRAME, typeFunc)endend
self:addEventListener(Event.ENTER_FRAME, typeFunc)endend-- Test
application:setLogicalDimensions(480, 800)local myconsole = console.new(1)
stage:addChild(myconsole)-- Generate sample txt local s =""for i =1, 10do
s = s.."TextField with typewriter effect. Drag to Scroll.\n\n"end-- Print
myconsole:tWrite(s)
Comments
Available since: Gideros 2017.10
@koeosstudio can you copy/paste your code please?
To have some text you need to change your code a little bit:
PS2: gideros 2019.10
PS3: if you don't understand some part just ask us
Likes: plicatibu
By the way, here's my final code : a simple Texfield with typwriter effect and basic scroll function.
Likes: MoKaLux
Can I add it to gideros wiki please?
Likes: MoKaLux
Likes: koeosstudio