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?
Yes yes, precisely something like this.
Where I could define a width and the text would be moving horizontally within that width.
- How long do you want it to take to wrap?
- Does it only wrap after the whole message was displayed (like above)?
- Does the message wrap on itself, like some Marquees?
- 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:
- Create a container (https://docs.coronalabs.com/api/library/display/newContainer.html) with the width and height you want.
- Add a background if you want.
- Create a text object with the whole message. (https://docs.coronalabs.com/api/library/display/newText.html#syntax-legacy)
- Change the x anchor of the object to 0.
- Insert the object into the container.
- Change the x-position of the text to half the width of the container.
- Transition the x-position of the text to x = (current X - width of text - width of container).
- 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.