Discord
Login
Community
DARK THEME

Scroll text

https://microstudio.io/jkeks/demo/9HRN3M7K/

example of scroll text. thruely right coordianates calculations.

init = function()
  text    = "Hello 😈 world"
  text_w  = screen.textWidth(text,24)
  start_x = screen.width/2+text_w/2
  text_x  = start_x
  text_y  = 0
end

update = function()
  text_x -= 2.6
  if (text_x < -start_x) then text_x = start_x end
end

draw = function()
  screen.clear()
  screen.drawText( text,text_x,text_y,24,"red")
end

There is just one liner

update = function()
  stepScroll=stepScroll%(screen.width+screen.textWidth(scrollText, 11))+1
end

draw = function()
  screen.drawText(scrollText, screen.width/2-stepScroll, screen.height/2 ,19,"white" )
end

! BUT! screen.textWidth calc incorrect

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community