Create a horizontal marquee

Needed to create a horizontal marquee for a text.
What’s an efficient approach to go about it?

Is this the effect you are trying to create?
scrolling_marquee

Yes yes, precisely something like this.
Where I could define a width and the text would be moving horizontally within that width.

  1. How long do you want it to take to wrap?
  2. Does it only wrap after the whole message was displayed (like above)?
  3. Does the message wrap on itself, like some Marquees?
  4. Smooth scrolling or stepped like above?

You need to think of all of these before designing a marquee or asking for help. There are so many factors, it is hard to give an answer w/o knowing.

Got you.

Pretty much exactly like the marquee you shared.
Although I’ll be looking to implement a smooth scrolling one.

In that case, the easiest way I can think of to make this is as follows:

  1. Create a container (https://docs.coronalabs.com/api/library/display/newContainer.html) with the width and height you want.
  2. Add a background if you want.
  3. Create a text object with the whole message. (https://docs.coronalabs.com/api/library/display/newText.html#syntax-legacy)
  4. Change the x anchor of the object to 0.
  5. Insert the object into the container.
  6. Change the x-position of the text to half the width of the container.
  7. Transition the x-position of the text to x = (current X - width of text - width of container).
  8. Choose a time to be equal to (1000 / (width of text + width of container) / speed_in_pixels_per_second .
    9 Be sure to add an onComplete function and have that onComplete function re-start the transition immediately or after a short delay.
1 Like

Wow, thanks a lot!
I’ll follow these steps.