Really?


function loops once and is recursive
Code:
PANEL* looptxt_pan =

{

	bmap = "nextstage.tga";
	pos_x = 1054;
	pos_y = 350;
	layer = 50;	
}
function fnc_looptxt()
{
var my_start_x = looptxt_pan.pos_x;  // when the functions call store the start points
var my_start_y = looptxt_pan.pos_y;
	wait(3);
	set(looptxt_pan,SHOW | OVERLAY);
	while(looptxt_pan.pos_x < screen_size.x - bmap_width(looptxt_pan.bmap))	
{  // while loop till bmap is at edge of screen

		looptxt_pan->pos_x +=30* time_step; // simple pixel shift by time_step

		wait(1);
	}
looptxt_pan.pos_x = my_start_x;  // restore panels start points
looptxt_pan.pos_y = my_start_y;
fnc_looptxt();   // I used a recursive function but you could use other methods for repeating the action

}



Please answer Uhrwerks question.

@Realspwans a5 forum made me a life long acknex user !!!
@Realspawn remove the last line and call manually from another function.

@wjbender The only reason to have a globe var is if you need to evaluate it in more then one function. And you waste resource tracking it's state. A globe var is only needed if other functions need to know the state of this panels pos and they can get it also by comparing vars that are built in panel.pos_x < screen_size.x-bmap_width(panel.bmap). The only reason I can see to make a global var and track it is to save 2 seconds of code typing.


function loops by counter ... add counter as a passible argument.
Code:
PANEL* looptxt_pan =

{

	bmap = "nextstage.tga";
	pos_x = 1054;
	pos_y = 350;
	layer = 50;	
}
function fnc_looptxt(var max_loops)
{
var loop_counter = 0; // to track loops
/// var max_loops = 5 ; // set to your max loops
var my_start_x = looptxt_pan.pos_x;  // when the functions call store the start points
var my_start_y = looptxt_pan.pos_y;
	wait(3);
	set(looptxt_pan,SHOW | OVERLAY);
	while(loop_counter <= max_loops)	
{  
if(looptxt_pan.pos_x>= screen_size.x - bmap_width(looptxt_pan.bmap))
{
 loop_counter +=1;
looptxt_pan.pos_x = my_start_x;  // restore panels start points
looptxt_pan.pos_y = my_start_y;
}
		looptxt_pan->pos_x +=30* time_step; // simple pixel shift by time_step

		wait(1);
	}
}




Also it's good method to write generalized functions, You might only want to 'scroll' this one panel but getting into the habit of writing functions that can be reused is will help in coding bigger projects. When you can write functions(methods) for their 'jobs' and not for their current 'owner/user' ent.

So ...

Code:
PANEL* looptxt_pan =

{

	bmap = "nextstage.tga";
	pos_x = 1054;
	pos_y = 350;
	layer = 50;	
}
function fnc_rightscroll_pan(PANEL* this_pan, var scroll_speed)
{
var my_start_x = this_pan.pos_x;  // when the functions call store the start points
var my_start_y = this_pan.pos_y;
	wait(3);
	set(this_pan,SHOW | OVERLAY);
	while(this_pan.pos_x < screen_size.x - bmap_width(this_pan.bmap))	
{  // while loop till bmap is at edge of screen

		this_pan->pos_x +=scroll_speed* time_step; // simple pixel shift by time_step

		wait(1);
	}
this_pan.pos_x = my_start_x;  // restore panels start points
this_pan.pos_y = my_start_y;
}

fnc_rightscroll_pan(looptxt_pan,30);


Last edited by Malice; 06/02/13 20:57.