Thanks Paolo, I decided to make a scroller by myself
local flw = fe.layout.width
local flh = fe.layout.height
class scroller {
text = null
time = null
delay = null
direction = null // left, right, top, down
end = null
start = null
current_tick_time = null
constructor( text_name, anim_time, anim_delay, anim_direction, anim_end ) {
text = text_name;
time = anim_time;
delay = anim_delay;
direction = anim_direction;
end = anim_end;
anim_prop()
fe.add_ticks_callback( this, "move" )
fe.add_transition_callback( this, "change_game" )
}
function anim_prop() {
current_tick_time = 0
switch ( direction ) {
case "top":
start = text.y;
end = text.y - end;
break;
case "down":
start = text.y;
end = text.y + end;
break;
case "left":
start = text.x;
end = text.x - end;
break;
case "right":
start = text.x;
end = text.x + end;
break;
}
}
function move( tick_time ) {
if ( current_tick_time == 0 ) {
current_tick_time = tick_time + delay // assign the current tick_time value to current_tick_time (it not increase durign time)
if ( direction == "top" || direction == "down" ) text.y = start
else text.x = start
}
local anim_time = tick_time - current_tick_time // anim_time increase every 16.6ms
if ( current_tick_time < tick_time ) {
switch ( direction ) {
case "top": if ( text.y > end ) text.y = start - anim_time / time; break; // do the movement
case "down": if ( text.y < end ) text.y = start + anim_time / time; break;
case "left": if ( text.x > end ) text.x = start - anim_time / time; break;
case "right": if ( text.x < end ) text.x = start + anim_time / time; break;
}
}
}
function change_game( ttype, var, ttime ) {
if ( ttype == Transition.ToNewList || ttype == Transition.ToNewSelection || ttype == Transition.ToNewList )
current_tick_time = 0 // assign value 0 to if game changes
}
}
local surface = fe.add_surface( flw*0.30, flh*0.30 );
surface.x = 50;
surface.y = 50;
local mytext = surface.add_text( "[Extra]", 0, 0, flw*0.30, flh*0.60 );
mytext.charsize = 15;
mytext.word_wrap = true;
mytext.align = Align.TopLeft;
mytext.set_bg_rgb( 255, 0, 0 );
scroller( mytext, 10, 500, "left", 50 ); // class call
but thanks to jedione I realized is easier using animation module with the text inside a surface
fe.load_module("animate");
local flw = fe.layout.width
local flh = fe.layout.height
local surface = fe.add_surface( flw/3, flh/3 );
surface.x = 100;
surface.y = 200;
local text = surface.add_text( "[Extra]", 0, 0, flw, flh );
text.charsize = 15;
text.word_wrap = true;
text.align = Align.TopLeft;
text.set_bg_rgb( 255, 0, 0 );
local an = { when=Transition.ToNewSelection, property="y", start=text.y, end=text.y-200, time=1000 }
animation.add( PropertyAnimation( text, an ) );