Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: Neosys on December 10, 2017, 07:33:56 AM

Title: ScrollingText by press a button
Post by: Neosys 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!
Title: Re: ScrollingText by press a button
Post by: liquid8d 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
Title: Re: ScrollingText by press a button
Post by: Neosys 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!
Title: Re: ScrollingText by press a button
Post by: liquid8d 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;
}