Author Topic: ScrollingText by press a button  (Read 5172 times)

Neosys

  • Full Member
  • ***
  • Posts: 50
    • View Profile
ScrollingText by press a button
« on: December 10, 2017, 07:33:56 AM »
Hello!

Can the ScrollingText module only display text in a layout when i press a button?

Thank you!

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: ScrollingText by press a button
« Reply #1 on: December 10, 2017, 05:12:35 PM »
No, in fact I don't think that is even part of that module, you'd have to implement stop/starting it with a button yourself  ;D

Neosys

  • Full Member
  • ***
  • Posts: 50
    • View Profile
Re: ScrollingText by press a button
« Reply #2 on: December 11, 2017, 08:43:50 AM »
Did I understand correctly that it would be possible with the button on and off?
But how? Can you help me?
Thanks!

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: ScrollingText by press a button
« Reply #3 on: December 11, 2017, 05:57:37 PM »
Yes, you can modify the scroll_obj.settings.speed_x and speed_y to speed up, slow down or stop scrolling. Tie this with a signal handler, and you are all set...

Here you go:
Code: [Select]
local scroller= ScrollingText.add( "This scroll can be stopped/started", 0, 0, fe.layout.width, 75, ScrollType.HORIZONTAL_BOUNCE );
fe.add_signal_handler(this, "on_signal");
function on_signal(str) {
    if ( str == "custom1" ) {
        //toggle horizontal scroll (use speed_y for vertical)
        if ( scroller.settings.speed_x == 1 ) {
            //stop scrolling
            scroller.settings.speed_x = 0;
            //reset text position (might want to change this depending on scroll type)
            scroller.text.x = 0;
            //reset to far right of scroll object
            //scroller.text.x = scroller.surface.width
        } else {
            //start scrolling
            scroller.settings.speed_x = 1;
        }
        return true;
    }
    return false;
}